Page 1 of 1

*** SOLVED *** Contact form submission always failing?

Posted: Sun Jun 30, 2019 3:29 pm
by newguy001
When testing my contact form and send my message, I am redirected to my error page, but I receive a notification email from my host provider I have messages waiting in my inbox. I have gone through the forums and have double checked everything, my contact page is .php, the success and error page is .html, I believe my settings are correct I have images on my contact page showing some settings if that will help, here is the link;
http://tester2.bestofvacations.com/Contact-Us.php

thank you in advance for any help or suggestions.

Re: Contact form submission always failing?

Posted: Sun Jun 30, 2019 3:42 pm
by Pablo
The name of the input field is not correct.
It should be 'email', not 'email:'

Re: Contact form submission always failing?

Posted: Sun Jun 30, 2019 4:50 pm
by newguy001
I changed the input to just email, is there any other settings that are easily missed for me to check? I have deleted and redone the form from scratch a few times now. Would using a floating layer or layout grid cause issues?

Re: Contact form submission always failing?

Posted: Sun Jun 30, 2019 5:02 pm
by Pablo
Did you republish the page?
Because the name is still the same.

Re: Contact form submission always failing?

Posted: Sun Jun 30, 2019 5:53 pm
by newguy001
I created a new form and still have the issue, and the input is email, not email: I'm at a lose

Re: Contact form submission always failing?

Posted: Sun Jun 30, 2019 6:08 pm
by Pablo
Can you please remove all dashes from the input names to see if that makes a difference?

Related FAQ:
https://forum.wysiwygwebbuilder.com/ ... 10&t=64868

Re: Contact form submission always failing?

Posted: Mon Jul 01, 2019 5:28 am
by newguy001
I have removed all special characters from the form input and label fields, as well as all object ID's and page names. Still having the same issue, it doesn't make sense, the forms have worked on other projects in the past.

Re: Contact form submission always failing?

Posted: Mon Jul 01, 2019 5:52 am
by Pablo
Basically the only reason why the form can fail is if one of the specified email addresses is invalid.

What is the PHP code of the form? (Menu -> Page -> Page HTML)

Re: Contact form submission always failing?

Posted: Mon Jul 01, 2019 12:27 pm
by newguy001
If I am reading this right the php code is not there;

<?php
function ValidateEmail($email)
{
$pattern = '/^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i';
return preg_match($pattern, $email);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['formid']) && $_POST['formid'] == 'contactusform1')
{
$mailto = 'information@bestofvacations.com';
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$subject = 'General Information';
$message = 'Values submitted from web site form:';
$success_url = './EmailReceived.html';
$error_url = './EmailNotReceived.html';
$autoresponder_from = 'Best of vacations';
$autoresponder_to = isset($_POST['email']) ? $_POST['email'] : $mailfrom;
$autoresponder_subject = 'General Information';
$autoresponder_message = 'Thank you for reaching out to us. We have received your message and will respond to you shortly.

Please note; There could be a delay of 4-5 business days to respond to any requests.

Sincerely;
Best Of Vacations Admin Team';
$eol = "\n";
$error = '';
$internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
$boundary = md5(uniqid(time()));
$header = 'From: '.$mailfrom.$eol;
$header .= 'Reply-To: '.$mailfrom.$eol;
$header .= 'MIME-Version: 1.0'.$eol;
$header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol;
$header .= 'X-Mailer: PHP v'.phpversion().$eol;
try
{
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address is invalid!\n<br>";
throw new Exception($error);
}

$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
foreach ($_POST as $key => $value)
{
if (!in_array(strtolower($key), $internalfields))
{
if (!is_array($value))
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol;
}
else
{
$message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol;
}
}
}
$body = 'This is a multi-part message in MIME format.'.$eol.$eol;
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol;
$body .= $eol.stripslashes($message).$eol;
if (!empty($_FILES))
{
foreach ($_FILES as $key => $value)
{
if ($_FILES[$key]['error'] == 0)
{
$body .= '--'.$boundary.$eol;
$body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol;
$body .= 'Content-Transfer-Encoding: base64'.$eol;
$body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol;
$body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol;
}
}
}
$body .= '--'.$boundary.'--'.$eol;
if ($mailto != '')
{
mail($mailto, $subject, $body, $header);
}
if (!ValidateEmail($autoresponder_from))
{
$error .= "The specified autoresponder email address is invalid!\n<br>";
throw new Exception($error);
}

$autoresponder_header = 'From: '.$autoresponder_from.$eol;
$autoresponder_header .= 'Reply-To: '.$autoresponder_from.$eol;
$autoresponder_header .= 'MIME-Version: 1.0'.$eol;
$autoresponder_header .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol;
$autoresponder_header .= 'Content-Transfer-Encoding: 8bit'.$eol;
$autoresponder_header .= 'X-Mailer: PHP v'.phpversion().$eol;
mail($autoresponder_to, $autoresponder_subject, $autoresponder_message, $autoresponder_header);
header('Location: '.$success_url);
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Contact Us</title>
<meta name="author" content="best of vacations">
<meta name="categories" content="travel">
<meta name="robots" content="index, nofollow">
<meta name="generator" content="https://bestofvacations.com">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon">
<link href="bettervacations_travelsite.css" rel="stylesheet">
<link href="Contact.css" rel="stylesheet">
<script>
function Validatecontactus()
{
var regexp;
var ContactnameEditbox4 = document.getElementById('ContactnameEditbox4');
if (!(ContactnameEditbox4.disabled || ContactnameEditbox4.style.display === 'none' || ContactnameEditbox4.style.visibility === 'hidden'))
{
regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ]*$/;
if (!regexp.test(ContactnameEditbox4.value))
{
alert("Name required");
ContactnameEditbox4.focus();
return false;
}
if (ContactnameEditbox4.value == "")
{
alert("Name required");
ContactnameEditbox4.focus();
return false;
}
}
var ContactemailEditbox5 = document.getElementById('ContactemailEditbox5');
if (!(ContactemailEditbox5.disabled || ContactemailEditbox5.style.display === 'none' || ContactemailEditbox5.style.visibility === 'hidden'))
{
regexp = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i;
if (!regexp.test(ContactemailEditbox5.value))
{
alert("Valid email required");
ContactemailEditbox5.focus();
return false;
}
if (ContactemailEditbox5.value == "")
{
alert("Valid email required");
ContactemailEditbox5.focus();
return false;
}
}
var ContactsubjectEditbox6 = document.getElementById('ContactsubjectEditbox6');
if (!(ContactsubjectEditbox6.disabled || ContactsubjectEditbox6.style.display === 'none' || ContactsubjectEditbox6.style.visibility === 'hidden'))
{
regexp = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ]*$/;
if (!regexp.test(ContactsubjectEditbox6.value))
{
alert("Subject required");
ContactsubjectEditbox6.focus();
return false;
}
if (ContactsubjectEditbox6.value == "")
{
alert("Subject required");
ContactsubjectEditbox6.focus();
return false;
}
}
var ContactmessageTextArea1 = document.getElementById('ContactmessageTextArea1');
if (!(ContactmessageTextArea1.disabled || ContactmessageTextArea1.style.display === 'none' || ContactmessageTextArea1.style.visibility === 'hidden'))
{
if (ContactmessageTextArea1.value == "")
{
alert("Valid message required");
ContactmessageTextArea1.focus();
return false;
}
}
return true;
}
</script>
</head>
<body>
<div id="wb_ContactLayoutGrid1">
<div id="ContactLayoutGrid1">
<div class="col-1">
<div id="wb_ContactText1">
<span id="wb_uid0"><strong>How May We Help You</strong></span>
</div>
<div id="wb_ContactText2">
<span id="wb_uid1"><strong>Thank you for reaching out to us, we value any suggestions you may have.<br>We will reply to any concerns or requests shortly.</strong></span>
</div>
</div>
</div>
</div>
<div id="ContactLayer1">
<div id="ContactLayer1_Container">
<div id="wb_ContactUsForm1">
<form name="contactus" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" id="ContactUsForm1" onsubmit="return Validatecontactus()">
<input type="hidden" name="formid" value="contactusform1">
<label for="ContactnameEditbox4" id="ContactnameLabel4">Name</label>
<input type="text" id="ContactnameEditbox4" name="name" value="" autocomplete="off" spellcheck="false">
<label for="ContactemailEditbox5" id="ContactemailLabel6">Email</label>
<input type="text" id="ContactemailEditbox5" name="email" value="" spellcheck="false">
<label for="ContactsubjectEditbox6" id="ContactsubjectLabel7">Subject</label>
<input type="text" id="ContactsubjectEditbox6" name="Contact-UsEditbox6" value="" spellcheck="false">
<label for="" id="ContactmessageLabel8">Message</label>
<input type="submit" id="ContactsendButton1" name="" value="Send">
<textarea name="ContactUsTextArea1" id="ContactmessageTextArea1" rows="12" cols="126" spellcheck="false"></textarea>
</form>
</div>
</div>
</div>
</body>
</html>

Re: Contact form submission always failing?

Posted: Mon Jul 01, 2019 1:04 pm
by Pablo
The auto responder 'from address' is invalid.

Code: Select all

$autoresponder_from = 'Best of vacations';
This should be a valid email address.

Re: Contact form submission always failing?

Posted: Mon Jul 01, 2019 3:42 pm
by newguy001
SOB!! :? its always the simplest things missed, all good now, thanks for your patience and help.