PHP is open source scripting language. It\'s widely used to develop web applications.  Home Web Programming PHP Form Email
Your Ad Here

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:

<?
$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!

<form method="post" action="contact.php">
Subject:<br />
<input type="text" name="subject" size="20"><br />
Email:<br /><input type="text" name="email" size="20"><br />
Comments:<br /><textarea cols="20" rows="5" name="comment"></textarea><br />
<input type="submit" value=" Submit "> </form>

which will produce the following

Subject:

Email:

Comments:

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.



Author's URL: Invano.com
Thank you for voting.
Rate this Materials:
Bad 
1 2 3 4 5 Excellent
print this page subscribe to newsletter subscribe to rss

Web programming � everything from the basics of visual design and architecture to the specifics of applications, graphics, and scripting. More Web Programming: Most Popular Materials | Fresh Materials | More PHP Tutorials at LearnPHP.org

Add comments to "Form Email"

Only registered users can write comment

No comments yet...