Thanks for looking at my thread. I have written the following code but constantly keep geting the following errors:
Notice: Undefined index: image1 in /Applications/MAMP/htdocs/ski/reviewsadmin/scripts/addreview.php on line 15
Notice: Undefined index: image1 in /Applications/MAMP/htdocs/ski/reviewsadmin/scripts/addreview.php on line 19
Notice: Undefined index: image1 in /Applications/MAMP/htdocs/ski/reviewsadmin/scripts/addreview.php on line 38
Sorry, there was a problem uploading your file.
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="skiguide"; // Database name
$tbl_name="reviews"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['image1']);
//This gets all the other information from the form
$pic1=($_FILES['image1']);
$time=date('d-F-Y');
$sql="INSERT INTO reviews (ID, time, category, title, by, image1, review, wheretobuy, website, price)
VALUES
('',
'$time',
'$_POST[category]',
'$_POST[title]',
'$_POST[by]',
'$pic1',
'$_POST[review]',
'$_POST[wheretobuy]',
'$_POST[website]',
'$_POST[price]')";
mysql_query($sql);
//Writes the photo to the server
if(move_uploaded_file($_FILES['image1']['tmp_name'], $target))
{
//Tells you if its all ok
header("Location: http://www.worldskiguide.co.uk/reviewsadmin");
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
Can anyone please help me.
Many Thanks,
Will