Can any body see what is wrong with my code, I just can't get it to work.
Thanks
PHP Code:
<?php
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
//input
//writes out selected if value matches variable value
function write_sel($val, $match) {
if ($val==$match) {
echo("checked");
}
}
//writes out "options" for all the referral methods
function write_referrals () {
$Referral = array("Search Engine", "Word of Mouth", "Advertisment", "Other");
foreach($Referral as $index => $val) {
if ($val == $GLOBALS["referrals"]) {
echo("<option value=\"$val\" selected>$val</option>\r\n");
} else {
echo("<option value=\"$val\">$val</option>\r\n");
}
}
}
$val_msg = "";
//if we are receiving a posted back form
if ($postback == "Y") {
//ensures that all fields are have been filled in correctly
if ($FirstName == "") {
$val_msg = "Please enter your <strong>first name</strong> and click submit.";
} elseif ($LastName == "") {
$val_msg = "Please enter your <strong>last name</strong> and click submit.";
} elseif ($Email == "") {
$val_msg = "Please enter your <strong>e-mail address</strong> and click submit.";
} elseif (!eregi("^[_\-\.0-9a-z]+@([0-9a-z][_0-9a-z\.]+)\.([a-z]{2,4}$)", $email)) {
$val_msg = "The e-mail address you entered is not valid. Please enter a valid <strong>e-mail address</strong> and click submit.";
}
if ($val_msg != "") {
$val_msg = "<font color='#FF0000' face='Arial, Helvetica, sans-serif' size='3'>Required field(s) were not properly filled out. " . $val_msg . "</font>";
} else {
//compose message
$msg = "The following is a request for additional information from your website.\r\n\r\n";
$msg .= "From: $FirstName$LastName\r\n";
$msg .= "E-mail: $Email\r\nPhone Number: $Phone\r\n\r\n";
$msg .= "Address:\r\n$Address\r\n$Address2\r\n$City\r\n$State, $Country\r\n$Zip\r\n\r\n";
$msg .= "Comments:$Comments\r\n\r\n";
$msg .= "How did you hear about us:$Referral\r\n";
//send e-mail and redirect
//first e-mail is where it will be sent to, next is title, then the message, the other headers
if (!mail("xxx@xxxx.com", "Additional Information", stripslashes($msg), "From: xxxx\r\nReply-to: $email\r\n")) {
$val_msg = "The system was unable to send your request. Please contact them directly via <a href='xxx@xxx.com'>e-mail</a> or by telephone / regular mail.";
} else {
//redirect the page to...may require modification
header("Location: http://xxxxx/html/thankyou.htm");
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
Can you narrow down by what you mean when you say it does not work? Do you get any error messages? If not, you might want to make sure all PHP errors are displayed with this at the start of your script:
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks