Form Email
This is a very simple tutorial, yet work like a charm and does all the things it needs to do. First of all, here's the code:
Lets break it down. The variables gather the information from the forms and make it a cleaner code. The if($submit) tells the mail(); function that it can send the email. It helps to keep it from sending annonymous emails to your email address.
You have to change the name@host.com to your email address to be able to get the email from the user. The rest is fine do not change, unless you need to.
Now for the forms!
which will produce the following
This is really simple, I should not have to explain it. Leave the name fields alone, unless you need to. You can change the size too.
<?
$subject = $_POST['subject']; // This is will be the subject of the email
$email = $_POST['email'];
$comments = $_POST['comments'];
$submit = $_POST['submit'];
if($submit)
{
// Replace name@host.com with your email address!
mail("name@host.com", "$subject", "$email", "$comments");
}
?>
Save it as contact.php
Lets break it down. The variables gather the information from the forms and make it a cleaner code. The if($submit) tells the mail(); function that it can send the email. It helps to keep it from sending annonymous emails to your email address.
You have to change the name@host.com to your email address to be able to get the email from the user. The rest is fine do not change, unless you need to.
Now for the forms!