This is a small script that I use to receive the contents of an enquiry form in a simple format.
It is very easy to use, just save this script as a PHP file, then in your HTML form use method="POST" action="scriptname.php".
You can add HTML insde the script to say "Thank You", or you can redirect to another page.
PHP Code:
<?php
//variables
//form contents
$txtName=$_POST['name'];
$txtCategory=$_POST['category'];
$txtCompany=$_POST['company'];
$txtTel=$_POST['telephone'];
$txtEmail=$_POST['email'];
$txtRequest=$_POST['request'];
$txtName = str_replace(array("\n","\r"),'',$txtName);
$txtEmail = str_replace(array("\n","\r"),'',$txtEmail);
$txtCC="copyaddress@wherever.com";
$txtBCC="hiddenaddress@wherever.com";
$txtMyemail="myemail@wherever.com";
$message = "Category :\t$txtCategory\n
\nCompany :\t$txtCompany\n
\nName :\t$txtName\n
\nTelephone :\t$txtTel\n
\nEmail :\t$txtEmail\n
\nRequest :\t$txtRequest\n
\n";
$subject = "Request For Information - $txtName - $txtCompany";
$mailheaders = "From: $txtEmail <> \n";
$mailheaders .= "Reply-To: $txtEmail\n\n";
$mailheaders .= "CC: ".$txtCC."\n\n";
$mailheaders .= "BCC: ".$txtBCC."\n\n";
$sendemail =$txtMyemail;
//send mail
mail($sendemail, $subject, $message , $mailheaders);
?>
You can add whatever other field values, from your form, you want into $message as long as they are converted to PHP variables using the $_POST method shown in the script.
To send a copy to the person who filled out the form you would put their email address into the $txtCC variable.
The email is not formatted in any way, it is just a 2 column list of descriptions and entered values.
Bookmarks