Hello, when some submits this form its get send to my email. If the picture or attachment has a space in it ( ex: tom file.docx) the hyperlink gets messed up.
I attach a picture of it below.
Thank you so much!
<?php
if(isset($_POST['email'])) {
$email_to = "talent@itarep.com";
function died($error) {
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
if ($_FILES["picture"]["error"] > 0)
{
//echo "Return Code: " . $_FILES["picture"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["picture"]["tmp_name"],
"pictures/" . $_FILES["picture"]["name"]);
$picture_url = "http://www.itarep.com/" . "pictures/" . $_FILES["picture"]["name"];
}
}
else
{
//echo "Invalid file";
}
if ($_FILES["attachment"]["error"] > 0)
{
//echo "Return Code: " . $_FILES["picture"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["attachment"]["tmp_name"],
"attachments/" . $_FILES["attachment"]["name"]);
$attachment_url = "http://www.itarep.com/" . "attachments/" . $_FILES["attachment"]["name"];
}
$name = $_POST['name'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$dobM = $_POST['dobM'];
$dobD = $_POST['dobD'];
$dobY = $_POST['dobY'];
$dobM = $_POST['dobM'];
$phone = $_POST['phone'];
$location = $_POST['location'];
$school = $_POST['school'];
$facebook = $_POST['facebook'];
$twitter = $_POST['twitter'];
$talent = $_POST['talent'];
$past = $_POST['past'];
$email_subject = $name . " - " . $gender . " - " . $dobY . " - " . $talent;
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Gender: ".clean_string($gender)."\n";
$email_message .= "Date of Birth: ".clean_string($dobM)."/".clean_string($dobD)."/".clean_string($dobY)."\n";
$email_message .= "Phone: ".clean_string($phone)."\n";
$email_message .= "Location: ".clean_string($location)."\n";
$email_message .= "University/High School: ".clean_string($school)."\n";
$email_message .= "Facebook: ".clean_string($facebook)."\n";
$email_message .= "Twitter: ".clean_string($twitter)."\n";
$email_message .= "Talent: ".clean_string($talent)."\n";
$email_message .= "Past work, Experiences, Expectations: ".clean_string($past)."\n";
$email_message .= "Picture: ".clean_string($picture_url)."\n";
$email_message .= "Attachment: ".clean_string($attachment_url)."\n";
// create email headers
$headers = 'From: '.$email."\r\n".
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<script type="text/javascript">
window.location = "http://www.itarep.com/success.php";
</script>
<?php
?>