Can any body see what is wrong with my code, I just can’t get it to work.
Thanks
[code=php]<?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>rn”);
} else {
echo(“<option value=”$val”>$val</option>rn”);
}
}
}
$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.rnrn”;
$msg .= “From: $FirstName $LastNamern”;
$msg .= “E-mail: $EmailrnPhone Number: $Phonernrn”;
$msg .= “Address:rn$Addressrn$Address2rn$Cityrn$State, $Countryrn$Ziprnrn”;
$msg .= “Comments:$Commentsrnrn”;
$msg .= “How did you hear about us:$Referralrn”;
//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(“[email protected]”, “Additional Information”, stripslashes($msg), “From: xxxxrnReply-to: $emailrn”)) {
$val_msg = “The system was unable to send your request. Please contact them directly via <a href=’[email protected]’>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”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<META http-equiv=Content-Type content=”text/html; charset=windows-1252″>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>
<body>
<table width=”412″ height=”180″ border=”0″ cellpadding=”0″ cellspacing=”0″>
<tr>
<td width=”145″ height=”12″ class=”contacttable”><p class=”contacttitle”>* First Name:</p></td>
<td width=”267″ height=”12″ class=”contacttable”>
<input name=”FirstName” type=”text” id=”FirstName” size=”20″ maxlength=”50″ value=”<?php echo($FirstName); ?>” /></td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>* Last Name:</p></td>
<td height=”12″ class=”contacttable”>
<input name=”LastName” type=”text” id=”LastName” size=”20″ maxlength=”50″ value=”<?php echo($LastName); ?>” />
</td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>Address:</p></td>
<td height=”12″ class=”contacttable”>
<input name=”Address” type=”text” id=”Address” size=”20″ maxlength=”50″ value=”<?php echo($Address); ?>” />
</td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>Address2:</p></td>
<td height=”12″ class=”contacttable”>
<input name=”Address2″ type=”text” id=”Address2″ size=”20″ maxlength=”50″ value=”<?php echo($Address2); ?>” />
</td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>City:</p></td>
<td height=”12″ class=”contacttable”>
<input name=”City” type=”text” id=”City” size=”20″ maxlength=”50″ value=”<?php echo($City); ?>”/>
</td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>State/Province:</p></td>
<td height=”12″ class=”contacttable”>
<input name=”State” type=”text” id=”State” size=”10″ maxlength=”30″ value=”<?php echo($State); ?>” />
</td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>Zip/Postal Code :</p></td>
<td height=”12″ class=”contacttable”>
<input name=”Zip” type=”text” id=”Zip” size=”10″ maxlength=”30″ value=”<?php echo($Zip); ?>”/>
</td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>Country:</p></td>
<td height=”12″ class=”contacttable”>
<input name=”Country” type=”text” id=”Country” size=”20″ maxlength=”50″ value=”<?php echo($Country); ?>”/>
</td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>Daytime Phone :</p></td>
<td height=”12″ class=”contacttable”>
<input name=”Phone” type=”text” id=”Phone” size=”15″ maxlength=”20″ value=”<?php echo($Phone); ?>”/>
</td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>* Email:</p></td>
<td height=”12″ class=”contacttable”>
<input name=”Email” type=”text” id=”Email” size=”20″ maxlength=”50″ value=”<?php echo($Email); ?>”/>
</td>
</tr>
<tr>
<td height=”12″ colspan=”2″ class=”contacttable”><p class=”thirdtitle”><span class=”contacttitle”>How did you hear about us?</span>
<select name=”Referral” size=”1″>
<option value=”” selected=”selected”><Select></option>
<?php write_referrals(); ?>
</select>
</p></td>
</tr>
<tr>
<td height=”12″ class=”contacttable”><p class=”contacttitle”>Comments/Questions/Information request:</p></td>
<td height=”12″ class=”contacttable”><p>
<textarea name=”Comments” cols=”25″ rows=”5″ id=”Comments”><?php echo($Comments); ?></textarea>
</p></td>
</tr>
<tr>
<td height=”12″ colspan=”2″><p>
<input type=”submit” name=”Submit” value=”Submit” />
<input type=”reset” name=”reset” value=”Reset” />
</p></td>
</tr>
</table>
</body>
</html>