dpdfh60088 2017-06-17 04:52
浏览 49

错误:“注意:未定义的索引”[重复]

  [Errors][1]

I posted the code that I edited, and there are new errors w/c i didn't understand

Notice: Undefined index: product_brand in C:\xampp\htdocs\JGMarketing\Admin_Area\insert_product.php on line 152

Notice: Undefined index: product_price in C:\xampp\htdocs\JGMarketing\Admin_Area\insert_product.php on line 153

Notice: Undefined index: product_images in C:\xampp\htdocs\JGMarketing\Admin_Area\insert_product.php on line 158

Notice: Undefined index: product_images in C:\xampp\htdocs\JGMarketing\Admin_Area\insert_product.php on line 159

<!DOCTYPE>

<?php

include("includes/db.php");


?>
<html>
<head>
    <title>Inserting Product</title>


    <script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
  <script>tinymce.init({ selector:'textarea' });</script>

</head> 
<body bgcolor="red">

<form action="insert_product.php"method="post"enctype= 
"multipart/form/data">
    <table align="center" width="700" border="5" bgcolor="white" >


    <tr>

        <td colspan="8"><h2 style="text-align:center;font-family:Arial;"> 
 Insert New Post Here</h2></td>

    </tr>


    <tr>
        <td align="right"><b>Product Name:</b></td>
        <td><input type="text" name= "product_name"  size="60" required />
 </td>

    </tr>

    <tr>
        <td align="right"><b>Product Category:</b></td>
        <td>

        <select name="product_cat" required>
            <option>Select Category</option>

            <?php

            global $con;
 $get_cat = "select * from categories";


 $run_cat = mysqli_query($con, $get_cat);

 while ($row_cat=mysqli_fetch_array($run_cat)){

    $cat_id= $row_cat['cat_id'];
    $cat_title= $row_cat['cat_title'];

 echo "<li><option>$cat_title</option></li>";

 }          
            ?>
            </select>

        </td>

    </tr>

    <tr>
        <td align="right"><b>Product Brand:</b></td>
        <td>

        <select name="product_brand" required>
            <option>Select Brand</option>

            <?php

            global $con;
 $get_brands = "select * from brands";


 $run_brands = mysqli_query($con, $get_brands);

 while ($row_brands=mysqli_fetch_array($run_brands)){

    $brands_id= $row_brands['brand_id'];
    $brands_title= $row_brands['brand_title'];

 echo "<li><option>$brands_title</option></li>";

 }

            ?>
            </select>





        </td>

    </tr>

    <tr>
        <td align="right"><b>Product Image:</b></td>
        <td><input type="file" name= "product_image" required /></td>

    </tr>

    <tr>
        <td align="right"><b>Product Price:</b></td>
        <td><input type="currency" name= "product_price" required/></td>

    </tr>

    <tr>
        <td align="right"><b>Product Description:</b></td>
        <td><textarea name="product_desc" cols="20" rows="10"></textarea>
    </td>

    </tr>

    <tr>
        <td align="right"><b>Product Keywords:</b></td>
        <td><input type="text" name= "product_keywords" size="50" 
    required /></td>

    </tr>



<tr align="center">


<td colspan="7"><input type="Submit" name= "insert_post" value="Insert 
Product Here"/></td>

    </tr>
</table>

</body>
</html>

 <?php


   if(isset($_POST['insert_post'])){

//getting text data
$product_name = $_POST['product_name'];
$product_cat = $_POST['product_cat'];
$product_brands = $_POST['product_brand'];
$product_price = $_POST['product_price'];
$product_desc = $_POST['product_desc'];
$product_keywords = $_POST['product_keywords'];

//getting image data
$product_image = $_FILES['product_images']['name'];
$product_image_tmp = $_FILES['product_images']['tmp_name'];

 move_uploaded_file($product_image_tmp,"products_images/$product_image");

 $insert_product = "insert into products 

(product_cat,product_brands,product_name,product_price,product_desc,
 product_img,product_keyword) values ('$product_cat','$product_brands'
 ,'$product_name','$product_price','$product_desc','$product_image'
 ,'$product_keywords')";

$run_product = mysqli_query($con,$insert_product);

if($run_product){

echo"<script>alert('Product Has been inserted')</script>";
echo"<script>window.open('insert_product.php','_self')</script>";

 }  
 }




 ?>
</div>
  • 写回答

3条回答 默认 最新

  • dongqi7631 2017-06-17 05:07
    关注

    You define your submit button name as "insert_post". But in if condition you take another name (if(isset($_POST['insert_product']))). Change the name.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?