I had this working a few days ago and for the life of me I do not know how the code broke. Basically I have a form where a user logs in and can update a profile and upload a pic. I assign a random number in front of the file name and upload the file with that new name. I then updated the table with this new name so I can reference it later for that specific user. Worked fine. NOW when I update the record and upload a photo it updates the Pic1 name for all records not just the unique one.
Here is part of the code, the entire page is past the character limit, I think I have made it more complex by using Dreamweavers built in PHP code for all of the form update except for this File Name process.
if($_POST['Update']){
$uploaddir = '/homepages/12/d114244980/htdocs/MaximumDirt/images/drivers/';
//begin file type check
if ($_FILES['userfile']['name']) {
$ext=substr($_FILES['userfile']['name'], -3);
if ($ext != "jpg" && $ext !="gif" && $ext !="JPG" && $ext !="GIF" && $ext !="Jpg" && $ext !="Gif") {
echo "ERROR!";
exit();
}
}
//end file type check
$picname = $_FILES['userfile']['name'];
if(empty($picname))
$random=rand(1000,9999);
$newpicname=$random.$picname;
$uploadfile = $uploaddir.$newpicname;
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
$sql_update = mysql_query ("UPDATE driver_profiles SET pic1='$newpicname'");
Can anybody please help me? I can send the entire PHP code to anyone who is willing to take a quick peek, I have been beating my head on this for over an hour!