Hello:
I just joined so still wet behind the ears. I can read and tweak code, but I'm no programmer.
I've been using a PHP script to create a contact form, display a message on Send and to send html email.
script begins with:
Code:
<?
function SafeHTML($string) {
$string = stripslashes($string);
$string = htmlspecialchars($string);
return nl2br($string);
}
function ValidateEmail($Email){
$result = ereg('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $Email);
if ($result){
return true;
} else {
return false;
}
}
$subject = $_POST['subject'];
$subject = SafeHTML($subject);
$name = $_POST['name'];
$name = SafeHTML($name);
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$telephone = SafeHTML($telephone);
$message = $_POST['message'];
$message = SafeHTML($message);
$contact = $_POST['contact'];
$contact = SafeHTML($contact);
switch($_GET[action]) {
case "check";
if(strlen($subject) > 0 && strlen($name) > 0 && strlen($telephone) > 0 && strlen($email) > 0 && strlen($message) > 0 && !strstr($message, "http") && !strstr($message, "href") && ValidateEmail($email) == true) {
$body=
followed with html email format
then
Code:
;
$headers = "From: $name <$email>\r\n";
$headers.="Content-type: text/html\r\n";
mail("client name <client@somedomain.com>","New email from your website",$body, $headers);
print "<div class='thanks'><p>Thank you for your email, <strong>$name</strong>.</p>
</div>";
} else {
print "<p class='star'><strong>You did not fill out all the required fields ( marked with * ) or you have entered an invalid email address. Please check the form and resubmit</strong></p>";
include("contactform.php");
}
break;
default:
include("contactform.php");
break;
}
?>
How do I add a conditional statement in the $headers mail part to redirect mail based subject?
Any assistance is much appreciated. thank you.
kp
Recent comments
11 hours 12 min ago
17 hours 53 min ago
21 hours 44 min ago
23 hours 22 min ago
1 day 7 hours ago
1 day 17 hours ago
1 day 18 hours ago
1 day 21 hours ago
2 days 2 hours ago
2 days 2 hours ago