|
First the php part:
My provider blocked the "from" header to receive mails from external websites so i arranged it a bit to send the mail from my domain and i read the customer email with the "name" tag
<?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
"; $email_subject = "your_desired_subject"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form your submitted. ";
echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form your submitted.'); }
$first_name = $_POST['email']; // required $customer_name = $_POST['name']; $email_from = "
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
"; // required (here u must provide a email adress from your domain) $comments = $_POST['comments']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'Your message do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Email: ".clean_string($first_name)."\n"; $email_message .= "Name: ".clean_string($customer_name)."\n"; $email_message .= "Internal Email: ".clean_string($email_from)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$first_name."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?>
<!-- include your own success html here -->
<p>Thank you for contacting us. We will be in touch with you very soon.</p> <p align="center"><a href="http://www.graphwire.com/">GO BACK!</a></p> <p> </p> <p> <? } ?> </p>
And part 2 is the table from your contact page:
<form name="contactform" method="post" action="send_form_email.php"> (send_form_email.php is the name i have for the first part u can name whatever but remember to modify this line then :D )
<table width="239" height="185" border="0"> <tr> <td><span class="style49"> <label for="first_name"><span class="style13">Name </span></label> </span></td> <td><input name="name" type="text" size="30" maxlength="50" /></td> </tr> <tr> <td><span class="style13 style41 style50">Email</span></td> <td><input name="email" type="text" size="30" maxlength="80" /></td> </tr> <tr> <td><span class="style49"> <label for="comments"><span class="style13">Your message</span></label> </span></td> <td><span class="style49"> <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> </span></td> </tr> <tr> <td> </td> <td><span class="style49" style="text-align:right"> <input type="submit" value="Send" /> </span></td> </tr>
</table> </form>
|