Search
Recommended Sites
Related Links






   

Informative Articles

Adding Sound to your Web Site - The Good, The Bad And The Ugly
Many webmasters like the idea of adding background music to their web sites but most shy away from doing it worrying about slow loading pages and large file sizes. There are many different ways to add background music to your site and some of them...

Dreamweaver: Your Professional Touch
Dreamweaver is sometimes seen as FrontPage's main competitor but, really, there's not even a comparison to be made. Dreamweaver might be expensive, sure, but there are serious web designers out there using it and getting work done - I...

How to make a simple form mailer with PHP
As you may be well aware, displaying your e-mail address on your website can lead to e-mail harvesters picking up your address and adding it to hundreds or even thousands of lists used by spammers. If you want to allow your website visitors to...

How To Make a Web Page
If you are able to create a document using a word processor like word then you are able to make a web page. Here we will look at how to make a web page using the Trellian WebPage page editor. Trellian Webpage is a WYSIWYG (what you see is...

President
please check attachment html file in the name of "COST OF A LETTER" About the Author all in the attachment...

 
PHP Form Mail Script

A Very simple PHP form processor that goes with the HTML form I created in the HTML forum.
<HTML> <HEAD> <TITLE>Thank You</TITLE> </HEAD> <BODY>
<?php
$date = date ("m/d/Y");
$name=$_POST['name']; $email=$_POST['email']; $comments=$_POST['comments'];
$to="youremail@yourdomain.com"; $subject="The subject for your email"; /* IE: Comments on $date */ $message="Comments from $name\n\nName: $name\nE-mail: $email\nComments: $comments"; $from="$email"; $headers="From: $email\n";
if (mail($to,$subject,$message,$headers)) { echo "<CENTER>Thank you for sending your comments</CENTER>"; } else { echo "There was a problem sending mail, this is a coding issue"; }
?>
</BODY> </HTML>
Lets get go through the explanation of this. You'll notice that I included the HTML tags as it's a good practice to get into. Most of you know how to begin a PHP statement by using <? and ending it with ?>, that's fairly simple.
$date = date ("m/d/Y");
This line configures the date, I enjoy using this and putting it somewhere in the processor, mainly the subject, so I know what date the comments were sent in on. This can be configured many different ways.
$name=$_POST['name']; $email=$_POST['email']; $comments=$_POST['comments'];
These three statements are how you get the information from the HTML form into this PHP processor. This takes from the POST method the HTML form and assigns the output into variables that we can use to produce the output. These output variables can differ depending on the info that your forms provide.
$to="youremail@yourdomain.com"; $subject="The subject for your email"; /* IE: Comments on $date */ $message="Comments from $name\n\nName: $name\nE-mail: $email\nComments: $comments"; $from="$email"; $headers="From: $email\n";
This is all the information to actually output the information. $to is the email address that you wish to send the comments to. $subject is the subject of the email that gets sent. $message is the formatted message that will be the body of the message with the variables, Note: \n skips 1 line. $from is the email address it's coming from, which isn't necessarily needed. $headers creates the headers for the email message, you should make it good attempt to do so, as some mail servers won't accept the mail without headers.
if (mail($to,$subject,$message,$headers)) { echo "<CENTER>Thank you for sending your comments</CENTER>"; } else { echo "There was a problem sending mail, this is a coding issue"; }
This is the piece of code that actually sends the email. PHP has a very simple command to send mail it's mail($to,$subject,$message,$headers); and is very self explanatory, as it mails using those variables. The if statement allows coding error control. If the email address entered isn't correct, or something is missing, it will post an error.
That concludes this PHP form mail tutorial. Please visit http://justincanada.net for more :). Thanks.
About the Author
Justin Robinson http://justincanada.net

Sign up for PayPal and start accepting credit card payments instantly.