Hello!
We have a contact form on our site. The user fills it out and the form goes to the rental company as well as the user email that they provided. We have a mail.php file that process the form data and sends the emails. This was all working fine but we are adding some elements and now we cannot get the form to function as we want it to.
We have set up a random number generator field to help eliminate some spam. We also have updated the code to make the fields required.
This is what I have found:
This is the form tag that we originally had does not check the new required fields coding. It goes right to the mail_2.php page:
<form action="http://www.ourcompany.com/mail_2.php" name="form1" method="post"><input type="hidden" name="submitForm" value="1" />
After reading some of your forum posts, I found some code and changed the form tags to read:
<form action="?" name="form1" method="post">
This correctly checks for errors but when it "redirects" to the mail.php page it does not seem to take any of the form info with it.
The code for the required fields is:
// process form
if (@$_REQUEST['submitForm']) {
// error checking
$errorsAndAlerts = "";
$check = $_REQUEST['check'];
$randomNumber = $_REQUEST['randomNumber'];
if (!@$_REQUEST['user_email']) { $errorsAndAlerts .= "You must enter your email!<br/>
\n"; }
else if(!isValidEmail(@$_REQUEST['user_email'])) { $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)<br/>
\n"; }
if (!@$_REQUEST['randomNumber']) { $errorsAndAlerts = "Please verify the number!<br/>\n"; }
if (($randomNumber != $check)) { $errorsAndAlerts = "Please enter the number shown!<br/>\n"; }
$requiredFields['user_name'] = 'Name';
$requiredFields['user_email'] = 'Email';
$requiredFields['message'] = 'Message';
$requiredFields['user_phone'] = 'Phone Number';
$requiredFields['agreecheck'] = 'Agree to Privacy Policy';
foreach ($requiredFields as $name => $label) {
if (!$label) { $label = $name; }
if (!@$_REQUEST[$name]) { $errorsAndAlerts .= "You must enter a value for '$label'!<br/>\n"; }
}
// send email
if (!$errorsAndAlerts) redirectBrowserToURL("http://www.rentittoday.com/mail_2.php";)
}
I am beginning to think that maybe we are not "redirecting" it correctly?
// send email
if (!$errorsAndAlerts) redirectBrowserToURL("http://www.rentittoday.com/mail_2.php";)
If anyone has any ideas they would be greatly appreciated!
Thank you,
Lauren
Jason Glass