注意:未定义的索引:第110行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\ [英] Notice: undefined index: product_image in C:\xampp\htdocs\ecommerce\admin_area\insert_product.php on line 110

查看:81
本文介绍了注意:未定义的索引:第110行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将product_image插入数据库时​​出现问题。我已经尝试了很多,但无法找出问题是什么



我尝试了什么:



There is issue with inserting product_image to database. I've tried a lot but couldn't find out what is the problem

What I have tried:

<!DOCTYPE html>
<?php
include("includes/db.php");
?>

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

	<title>Inserting new product</title>

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

<tr align="center">
	<td colspan="7"><h2 align="center">Insert new product here</h2></td>
</tr>

<tr>
	<td align="right">Product title:</td>
	<td><input type="text" name="product_title" size="60" /></td>

</tr>
<tr>
	<td align="right">Product Category:</td>
	<td><select name="product_cat">
		<option>Select a category</option>

		<?php

	$get_cats = "select * from categories";
	$run_cats= mysqli_query($con,$get_cats);

	while ($row_cats=mysqli_fetch_array($run_cats)) {

		$cat_id = $row_cats['cat_id'];
		$cat_title = $row_cats['cat_title'];
		echo "<option value='$cat_id'>$cat_title</option>";
	}
	?>
	</select>
	</td>

</tr>
<tr>
	<td align="right">Product Brand:</td>
	<td><select name="product_brand">
<option>Select a Brand</option>
<?php

    $get_brands = "select * from brands";
	$run_brands= mysqli_query($con,$get_brands);

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

	  $brand_id = $row_brands['brand_id'];
	  $brand_title = $row_brands['brand_title'];
	  echo "<option value='$brand_id'>$brand_title</option>";
	}
?>
</select>


	</td>

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

</tr>
<tr>
	<td align="right">Product price:</td>
	<td><input type="text" name="product_price"/></td>

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

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

</tr>
<tr align="center">
		<td colspan="7"><input type="Submit" name="insert_post" value="Insert now" /></td>

</tr>
</table>

</body>
</html>

<?php
if(isset($_POST['insert_post'])){

//getting the text data from the fields
$product_title = $_POST['product_title'];
$product_cat = $_POST['product_cat'];
$product_brand = $_POST['product_brand'];
$product_price = $_POST['product_price'];
$product_desc = $_POST['product_desc'];
$product_keywords = $_POST['product_keywords'];
 // getting the image from the fields
$product_image=$_FILES['product_image']['name'];
$product_image_tmp=$_FILES['product_image']['tmp_name'];

echo $insert_product = "INSERT INTO products(product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords) values('$product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_image','product_keywords')";

}

推荐答案

get_cats =select * from categories;
get_cats = "select * from categories";


run_cats = mysqli_query(
run_cats= mysqli_query(


con,


这篇关于注意:未定义的索引:第110行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆