Form Validation Alert
Posted: Tue Nov 25, 2008 3:01 pm
So i've got a form that has a few text fields and some check boxes on it & on my php page I have a validation, as shown below, so that if one of the fields or checkbox is empty/unselected it goes back to the form. What I want to add is an alert box that shows up after it goes back to the page so the visitor knows the form wasn't actually submitted due to the form not being completed.
Here's the code from the php page:
I know an easy fix to this would be to make the header("Location: contact.htm") go to a secondary contact page, but I'd prefer to have a popup but am not sure how to do this. I've also tried adding a few things above and below header("Location: contact.htm") that have been unsuccessful, so if anyone has any ideas it would be much appreciated!
Here's the code from the php page:
Code: Select all
<?
if (($_POST[senderName] == "") ||
($_POST[senderEmail] == "") ||
($_POST[message] == "") ||
(!isset($_POST['check']))) {
header("Location: contact.htm");
exit;
}
$to = "me@site.com";
$subject = "CONTACT INQUIRY";
$mailheaders = "From: Info <me@site.com>\n";
$mailheaders .= "Reply-To: $_POST[senderEmail]\n";
foreach($_POST['check'] as $value) {
$checkBox .= "$value\n";
}
$msg .= "Senders Name:\t$_POST[senderName]\n";
$msg .= "Senders Email:\t$_POST[senderEmail]\n";
$msg .= "Message:\t$_POST[message]\n";
$msg .= "Checked boxes:\t $checkBox\n";
mail($to, $subject, $msg, $mailheaders);
?>