Forum Moderators: coopster
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="css/lightbox.css" rel="stylesheet" />
</head>
<body>
<?php
if (isset($_POST['submit'])) {
$error = "";
if (!empty($_POST['Name'])) {
$name = $_POST['Name'];
} else {
$error .= "You didn't type in your name. <br />";
}
if (!empty($_POST['Email'])) {
$email = $_POST['Email'];
if (!preg_match("/^[_a-z0-9]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "The e-mail address you entered is not valid. <br/>";
}
} else {
$error .= "You didn't type in an e-mail address. <br />";
}
if (!empty($_POST['Message'])) {
$message = $_POST['Message'];
} else {
$error .= "You didn't type in a message. <br />";
}
if (!empty($_POST['Telephone'])) {
$telephone= $_POST['Telephone'];
}
if(($_POST['code']) == $_SESSION['code']) {
$code = $_POST['code'];
} else {
$error .= "The captcha code you entered does not match. Please try again. <br />";
}
if (empty($error)) {
$from = 'From: ' . $name . ' <' . $email . '>';
$to = "email@emial.com";
$subject = "Message from website";
$content = " From: ".$name . "\n Phone number: " . $telephone . "\n Message: " . $message;
$success = "<h3>Thank you! Your message has been sent!</h3>";
mail($to,$subject,$content,$from);
}
}
?>
<p> </p>
<table align="center" width="1090" border="0" >
<tr>
<td valign="top">
<div class="Contactpage-BG">
<table border="0" align="left" width="100%">
<tr>
<td>
</td>
</tr>
<tr>
<td align="left">
<div class="Testimonial">
<div class="Contact-BG">
<div class="Contact-Midleft">
</div>
<div class="Contact-text">
<p class="Contact-text"><i> *Compulsory Fields</i> </p>
</div>
<form method="post" action="" >
<table width="600" height="531" border="0" cellpadding="0">
<tr>
<td width="111" height="28" class="Contact-text"><div class="Contactboxes-name-label">*Name:</div></td>
<td colspan="2">
<input name="Name" type="text" class="Contactboxes-name" id="Name" value="<?php echo $_POST['name']; ?>"/>
</td>
</tr>
<tr>
<td height="28" class="Contact-text"><div class="Contactboxes-email-label">*Email:</div></td>
<td colspan="2"><input name="Email" type="text" size="60" class="Contactboxes-email" id="Email" value="<?php echo $_POST['email']; ?>"/></td>
</tr>
<tr>
<td height="28" class="Contact-text"><div class="Contactboxes-telephone-label"> Telephone:</div></td>
<td colspan="2"><input name="Telephone" type="text" class="Contactboxes-telephone" id="Telephone" value="<?php echo $_POST['telephone']; ?>"/></td>
</tr>
<tr>
<td height="139" valign="top" class="Contact-text"><div class="Contactboxes-message-label">*Message:</div></td>
<td colspan="2"><textarea name="Message" cols="56" rows="11" class="Contacttextarea" id="Message"><?php echo $_POST['message']; ?></textarea></td>
</tr>
<tr>
<td valign="top" class="Contact-text"><div class="Contactboxes-spam-label">*Anti-SpamBot Code:</div></td>
<td colspan="2" valign="top"><div class="Contactboxes-spam">Please enter the numbers you see in this image<br />
into the box below</div></td>
</tr>
<tr>
<td height="51"> </td>
<td width="209" valign="top"><div class="Captchaimagebox"><label><img src="captcha.php"></label></div></td>
<td width="252" rowspan="3" valign="top">
<?php
if (!empty($error)) {
echo '<p class="error"><font color="#FF0000"><strong>Your message was NOT sent</strong></font><br/>' . $error . '</p>';
} elseif (!empty($success)) {
echo $success;
}
?>
</td>
</tr>
<tr>
<td height="48"> </td>
<td valign="top"><input name="code" type="text" class="Captchabox"></td>
</tr>
<tr>
<td height="65"> </td>
<td><input type="submit" class="Contact-Send" name="submit" value="" /></td>
</tr>
</table>
<p>
<div class="contactfields">
<label for="Name"></label></div></p>
</form>
</div>
<div class="Contact-Midright"></div>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>
<input name="Email" type="text" size="60" class="Contactboxes-email" id="Email" value="<?php echo $_POST['email']; ?>"/>