4194304) { $errors[] = "File exceeds 4 megabytes"; } if (!$_POST['comment']) { $errors[] = "A comment is required"; } if (!$_POST['email']) { $errors[] = "Your email is required"; } if (!preg_match('/\b([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+[a-zA-Z]{2,4})\b/', $_POST['email'])) { $errors[] = "Incorrect email"; } if (eregi("to:", $_POST['email']) || eregi("cc:", $_POST['email'])) { $errors[] = "Invalid comment"; } if (count($errors) > 0) { echo "

\n"; echo "

The following error(s) occured


\n"; foreach ($errors as $err) { echo "
  • $err

  • \n"; } echo "
    \n"; } else { if (file_exists("images/".$_FILES['image']['name'])) { $s = 1; while (file_exists("images/".$s."-".$_FILES['image']['name'])) { $s++; } $path = "images/".$s."-".$_FILES['image']['name']; } else { $path = "images/".$_FILES['image']['name']; } move_uploaded_file($_FILES['image']['tmp_name'], $path); echo "Thank you for submitting your image. We will get back to you as soon as possible\n"; $to = 'graham.bull@gmail.com'; $subject = 'Hot Photo Shot Submission'; $message = wordwrap("IP: ".$_SERVER['REMOTE_ADDR']."\n Image link: Here\n Comment: ".htmlentities($_POST['comment']), 70); $headers = "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= 'From: '.$_POST['email']."\r\n"; mail($to, $subject, $message, $headers); } } else { echo '
    Image:
    Comment:
    Email:
     
    '; } ?>