I have a form on my website that calls a PHP script hosted on another website. The script is supposed to generate two emails - one to me to alert that the form has been filled out, and one to the user as a confirmation email. This script used to work fine, but since switching hosts and enabling SSL, it now just redirects me to a blank page with the PHP file in the address bar with ?i=1 after it instead of generating the emails and redirecting me to the “thank you” page. This script is kind of old and might be outdated - I don’t have a ton of experience with PHP and my entire site is reverse engineered and jerry rigged. But if anyone can help figure out where the problem is, I will be eternally grateful.
if(isset($_POST['email'])) {
// CHANGE THE TWO LINES BELOW
$email_to = "[email protected]";
$email_toa = "[email protected]";
$email_subject = "Kami-Con HAI 2024 - AMV Submission";
$conf_subject = "Kami-Con HAI 2024 - AMV Contest Confirmation";
function died($error) {
// your error code can go here
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 click BACK in your browser and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['handle']) ||
!isset($_POST['amv_category']) ||
!isset($_POST['youtube'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
if(!empty($_POST['first_name'])) {}
else{
died('First name is required.');
}
if(!empty($_POST['last_name'])) {}
else{
died('Last name is required.');
}
if(!empty($_POST['amv_title'])) {}
else{
died('Title of AMV is required.');
}
if(!empty($_POST['amv_song'])) {}
else{
died('Song Used is required.');
}
if(!empty($_POST['amv_artist'])) {}
else{
died('Song Artist is required.');
}
if(!empty($_POST['amv_anime'])) {}
else{
died('Animation sources are required.');
}
if(!empty($_POST['amv_link'])) {}
else{
died('AMV link is required.');
}
if(!empty($_POST['attending'])) {}
else{
died('Are you attending the convention? This answer is required.');
}
if(!empty($_POST['email'])) {}
else{
died('Email address is required.');
}
if(!isset($_POST['consent'])) {
died('You must check that you have read and understand the AMV League Rules and Criteria to submit a video.');
}
function IsChecked($chkname,$value)
{
if(!empty($_POST[$chkname]))
{
foreach($_POST[$chkname] as $chkval)
{
if($chkval == $value)
{
return true;
}
}
}
return false;
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$handle = $_POST['handle']; // not required
$amv_title = $_POST['amv_title']; // required
$amv_category = $_POST['amv_category']; // required
$amv_song = $_POST['amv_song']; // required
$amv_artist = $_POST['amv_artist']; // required
$amv_anime = $_POST['amv_anime']; // required
$amv_link = $_POST['amv_link']; // required
$email_from = $_POST['email']; // required
$attending = $_POST['attending']; // required
$youtube = $_POST['youtube']; // not required
$consent = $_POST['consent']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z' .-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$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($first_name)." ".clean_string($last_name)."\n";
$email_message .= "Handle: ".clean_string($handle)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Title of AMV: ".clean_string($amv_title)."\n";
$email_message .= "Category: ".clean_string($amv_category)."\n";
$email_message .= "Song: ".clean_string($amv_song)." by ".clean_string($amv_artist)."\n";
$email_message .= "Anime Used: ".clean_string($amv_anime)."\n\n";
$email_message .= "Youtube: ".clean_string($youtube)."\n\n";
$email_message .= clean_string($amv_link)."\n\n\n";
$amv_category = strtoupper($amv_category);
$email_message .= clean_string($amv_category)."\n";
$email_message .= clean_string($amv_title)."\n";
$email_message .= "\"".clean_string($amv_song)."\""."\n";
$email_message .= clean_string($amv_artist)."\n";
$email_message .= clean_string($amv_anime)."\n";
$email_message .= "Editor: ".clean_string($handle)."\n\n";
$email_message .= "Attending? ".clean_string($attending)."\n\n";
$email_message .= "Full Name: ".clean_string($first_name)." ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n\n";
$email_message .= "Download: ".clean_string($amv_link)."\n";
$email_message .= "Streaming: ".clean_string($youtube)."\n\n";
$conf_message .="Thank you for your interest. We have received the following submission from you: \n\n";
$amv_category = strtoupper($amv_category);
$conf_message .= clean_string($amv_category)."\n";
$conf_message .= clean_string($amv_title)."\n";
$conf_message .= "\"".clean_string($amv_song)."\""."\n";
$conf_message .= clean_string($amv_artist)."\n";
$conf_message .= clean_string($amv_anime)."\n";
$conf_message .= "Editor: ".clean_string($handle)."\n\n";
$conf_message .= "Full Name: ".clean_string($first_name)." ".clean_string($last_name)."\n";
$conf_message .= "Email: ".clean_string($email_from)."\n\n";
$conf_message .= "Download: ".clean_string($amv_link)."\n";
$conf_message .= "Streaming: ".clean_string($youtube)."\n\n";
$conf_message .= "We will review this submission at our earliest convenience and contact you if there are any further issues.\n\n";
$conf_message .= "Regards,\n";
$conf_message .= "Annie Bowyer\n";
$conf_message .= "Vitamin H Productions\n";
$conf_headers = 'From: '.$email_toa."\r\n".
'Reply-To: '.$email_toa."\r\n" .
'X-Mailer: PHP/' . phpversion();
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
mail($email_from, $conf_subject, $conf_message, $conf_headers);
header( 'Location: http://vitaminh.weebly.com/thankyou.html' ) ;
}
die();
?>
type or paste code here