hy! this is my html code....
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add New Templete</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php include 'side.php'; ?>
<div class="main">
<h2>Add New Templete</h2>
<form method="post" action="add.php" enctype="multipart/form-data">
<table border="1px solid">
<tr>
<td>Templete Name:</td><td><input type="text" name="temp_name"></td></tr>
<tr>
<td>Templete Category</td><td><input type="text" name="category"></td></tr>
<tr>
<td>Templete Image</td><td><input type="file" name="image"></td></tr>
<tr>
<td>Templete Discription</td><td><input type="text" name="decp"></td></tr>
<tr>
<td>Templete Quantity</td><td><input type="text" name="qty"></td></tr>
<tr>
<td>Templete Price</td><td><input type="text" name="price"></td></tr>
<tr>
<td></td>
<td>
<input type="submit" value="ADD">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
and this is my php code
<?php
include 'connection.php';
$name=$_POST['temp_name'];
$cat=$_POST['category'];
$image=$_POST['image'];
$desc=$_POST['decp'];
$qty=$_POST['qty'];
$price=$_POST['price'];
$qry="INSERT INTO templetes(templete_name,category,image,description,quantity,price)VALUES('$name','$cat','$image','$desc','$qty','$price')";
$res=mysql_query($qry,$con);
if($res)
{
echo "record inserted";
}
mysql_close($con);
?>
Every thing are fine the data will be stored in database but the image are not stored in database, it says "undefined index image on ....... line ...." means it will show the undefined index error. all the data will stored except the image?
imageis a file, so its information is stored in$_FILES, not$_POST.mysql_*functions to either MySQLi or PDO. You should also learn about "prepared statements", which is currently the safest way to run SQL queries with user input.