I'm working on trying to approve photos that get posted. It works fine, but to keep files with the same name from overwriting each other I went with assigning them a random number. The problem is that even if a file is not uploaded it still writes a random number to the table and it shows up in the admin as an unknown file extension. I can't get it to not submit if no file is posted. Any ideas?
//Assign random number
$ran = rand () ;
// Add . to random number
$ran2 = $ran.".";
$ext = getExtension ($_FILES['photo']['name']) ;
if(!isset($_FILES['photo']['name']))
{
$ran2='';
$ext='';
}
// Insert fields into XINFO
$sql = "INSERT INTO xinfo (userid, date_submit, first_name, last_name, city, state_province, country, dob, email, photo)
VALUES ('$id', '$dsub','$fn', '$ln', '$city', '$state', '$cntry', '$dob', '$em', '$ran2$ext')";