The easiest form to email script I ever did write!
I got completely fed up recently with writing long form to email scripts, testing them and spending the time to get them working. Quite often a small spelling mistake would lead to failure of something, sometimes going unseen for a while.
But then two sites came along at the same time each with several different contact forms, some quite lengthy. It was obviously going to take a few hours to code them all up, so that became a few hours that could be better spent developing a quick and easy solution to roll out to any website almost instantly.
And that is what I achieved. Now, it takes seconds to do the form to email processing! I just copy in a standard send.php page, change the destination email and the job is done!
I’ve been sharing this with a few customers who maintain their own sites, so I thought why not share it further? So I am documenting it here for all to use.
It is not that clever and not that long. The only requirement, apart from needing some version of PHP, is that the form is submitted with the method=”POST”. Then it does everything else the same. Just give the fields names that are meaningful and this little script will do the rest.
Just cut and paste the code below into the top of a PHP thank you page, change the $site_email to your own email and it should work! Simple as that.
foreach ( $_POST as $key => $value ) {
$message .= ‘<b>’.$key . “</b><br>” . str_replace(“\r\n”, “<br>”, $value).’<br><br>’;
}
$site_email = ‘box@youremail.com’;
ini_set(“sendmail_from”, $site_email);
$subject = ‘Website Enquiry Received’;
$headers = ‘From: ‘.$site_email.”\r\n” .
‘Content-type: text/html;’.”\r\n”.
‘Reply-To: ‘.$site_email. “\r\n” .
‘X-Mailer: PHP/’ . phpversion();
mail($site_email, $subject, $message, $headers);
Related posts:
- PayPal GoDaddy Phishing Email
- Sample PayPal Phishing Email
- FREE email upgrade worth £14.99, From namesco
- How CSS Can Clean Up a Website’s Code
- Phishing For Email Access Now!
- Getting More Free Web Traffic – Part 12, Should I Pay Someone To Write For Me?
- Getting More Free Web Traffic – Part 13, Finding Ideas To Write About
- BlogAdvertisingStore & PayingPost – Scam or Genuine?
- Don’t Get Carried Away With Images
- Having A Fresh Weblog Included In The Technorati List














Leave a Reply