Hey guys.... please help me out on sorting this php issue... i have made a form to upload images to folder and its details to database but not able to code a form to retrive image from folder and its details from database.
HTML form -
<form method="post" action="addMember.php" enctype="multipart/form-data">
<p>
</p>
<p>
Product Name
</p>
<input type="text" name="productname"/>
<br><p>
Product Image:
</p>
<input type="hidden" name="size" value="350000">
<input type="file" name="photo">
<br>
<p>
Product Details :
</p>
<textarea rows="10" cols="35" name="productdetails">
</textarea>
<br/>
<br/>
<input TYPE="submit" name="upload" title="Add data to the Database" value="Submit"/>
</form>
addMember.php -
<?php
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$name=$_POST['productname'];
$pic=($_FILES['photo']['name']);
$about=$_POST['productdetails'];
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error()) ;
mysql_select_db("emp") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO empp (productname,photo,productdetails)
VALUES ('$name', '$pic', '$about')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>