<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Upload photo 1</title>
<form method="post" action="upload.php" enctype="multipart/form-data">
<p>
Photo name:
</p>
<input type="text" name="Name"/>
<p>
Category : --->
Choose Between Animals, Cars , Landscapes , People
</p>
<input type="text" name="Category"/>
<p>
Creator </p>
<input type="text" name="Creator"/>
<p>
Upload your photo :
<input type="file" name="photo">
<input TYPE="submit" name="upload" title="Add data to the Database" value="Add Photo"/>
</form>
<br/>
</center>
</head>
<?php
//This is the directory where images will be saved
$target = "C/documents";
$target = $target . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$name=isset($_POST['name']) ? $_POST['name'] : '';
$category=isset($_POST['category']) ? $_POST['category'] : '';
$pic=isset($_POST['photo']) ? $_POST['photo'] : '';
$creator=isset($_POST['creator']) ? $_POST['creator'] : '';
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error()) ;
mysql_select_db("gallery") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO images (name,category,photo,creator)
VALUES ('$name', '$category', '$pic', '$creator'") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['photo']['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.";
}
?>
Hello guys..I need your help here. I am getting these 2 errors every time I open this form
Notice: Undefined index: photo in C:\xampp\htdocs\upload.php on line 37
Notice: Undefined index: photo in C:\xampp\htdocs\upload.php on line 56
Can anyone help me out what I'm doing wrong?? Thank you! :)