hi i have a simple form where user can insert their name email phone and upload a image.
the form and the php work fine but i wod like my php script to rename the uploaded image to a unique number or naame before saving it to my database and image folder. pls can any one help i am going mad
form script:
<html>
<head>
<title></title>
</head><body>[/color]<form enctype="multipart/form-data" action="add.php" method="post">
Name: <input name="name" type="text"><br>
E-mail: <input name="email" type="text"><br>
Phone: <input name="phone" type="text"><br>
Photo: <input name="photo" type="file"><br>
<input value="Add" type="submit">
</form></body></html>
php script:
<?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['name'];
$email=$POST['email'];
$phone=$POST['phone'];
$pic=($FILES['photo']['name']);
// Connects to your Database
mysql_connect("mysql6.000webhost.com", "a3205133_test", "sid801142") or die(mysql_error()) ;
mysql_select_db("a3205133_test") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO employees
VALUES ('id','$name', '$email', '$phone', '$pic')") ;
//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.";
}
?>
any help wod be good thanx