need help with placing IF ELSE on contact form
Posted: Wed Jul 20, 2005 1:31 pm
with my form validation code
I need to add...
if(this error || that error || some other error) {
print error;
} else {
//no errors, thank them!
print THANKS!
}
to get it to work like I want, but I am not sure where to add the || and else in the above code.
any help??
thanks in advance!
Code: Select all
<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$email2 = $_POST['email2'];
$URL = $_POST['URL'];
$Contact_Preference = $_POST['Contact_Preference'];
$Contact_Time = $_POST['Contact_Time'];
$message = $_POST['Message'];
if ((!$firstname) || (!$Contact_Preference)) {
echo'<p><strong>Error!</strong> Fields marked <span class="red"> *</span> are required to continue.</p><br />';
echo'<p>Please go back to the <a href="Contact.php"title="Contact Me">Contact Me</a> page and try it again!</p>';
}
if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)) {
echo '<p>Invalid email address entered.</p><br />';
echo '<p>Please go back to the <a href="Contact.php" title="Contact Me">Contact Me</a> page and try it again!</p>';
}
if (($email) != ($email2)) {
echo '<strong>Error!</strong> e-mail addresses dont match.<br />';
}
$email_address = "webguync@gmail.com";
$subject = "There has been a disturbance in the force";
$message = "Request from: $firstname $lastname\n\n
Company name: $company\n
Phone Number: $phone\n
Email Address: $email\n
URL: $URL\n
Please Contact me via: $Contact_Preference\n
The best time to reach me is: $Contact_Time\n
I wish to request the following additional information: $Textarea";
mail($email_address, $subject, $message, "From: $email \nX-Mailer: PHP/" . phpversion());
echo "<p>Hello, <strong>$firstname</strong>.<br /><br />
We have received your request for additional information, and will respond shortly.<br />
Thanks for visiting inspired-evolution.com and have a wonderful day!<br /><br />
Regards,<br /><br />
<strong>Inspired Evolution</strong></p>";
?>if(this error || that error || some other error) {
print error;
} else {
//no errors, thank them!
print THANKS!
}
to get it to work like I want, but I am not sure where to add the || and else in the above code.
any help??
thanks in advance!