Forum Moderators: coopster
I am trying to keep this very basic and this script was adapted from the internet.
Any suggestion's would be grateful
<div id="contactform">
<?php
if(isset($_POST['submit']))
{
// process the form
$from = "From: <myemail@myserver>";
$to = "email addy of where i want form to go";
if ($_SERVER['REQUEST_METHOD']!= "POST"){exit;}
// validate the email addy
$disallowed_email = array(':',';',"'",'"','=','(',')','{','}');
foreach($disallowed_email as $value)
{
if(stristr($_POST['Email'],$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}
}
//$message = "";
// This line prevents a blank form being sent
//while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}
$name = $_POST["Name"];
$email = $_POST["Email"];
$tel = $_POST["Tel"];
$comments = $_POST["Comments"];
// check the email format
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
{
echo "<h3>Error!</h3><p class=\"error\">Please enter a valid e-mail address</p>";
$valid = "false";
}
if($valid!= "false")
{
$message = $comments . "Why doesnt this form work?";
$message = stripslashes($message);
$subject = "My Website Form";
$headers = "From: " . $email . "\n" . "Return-Path: " . $email . "\n" . "Reply-To: " . $email . "\n";
mail($to,$subject,$message,$from);
echo "<p><b>Thank you <?php print stripslashes($name);?>!</b><br /><a class=\"bodylink\" href=\"".$continue."\">Click here to go back...</a></p>";
}
}
else
{
?>
<div class="formtext">
<form action="newBooking.php" method="post">
Name<br />
<input type="text" name="Name" class="formInput" /><br />
E-Mail Address<br />
<input type="text" name="Email" class="formInput" /><br />
Telephone Number<br />
<input type="text" name="Tel" class="formInput" /><br />
Booking Details<br />
<textarea name="Comments" rows="6" cols="50" class="formInput"></textarea><br />
<input type="submit" name="submit" value="Send" />
</form>
<br />
</div>
<?
}
?>
</div>