Form mail using PHP

PHP, Programing Add comments

One of the most important scripts which is used online is the Mail Form. Fortunately, PHP makes it extremly easy to use form mail, using the mail() function. So the Form Mail we're going to make is going to be broken does into 2 parts. One part has the HTML for the form and the second part is the processing for the form. However, we have to work backwards and do the processing before hand. We will ask three things on the form to keep it simple: their name, their e-mail address, and their comments. Lets get started with the first part:

PHP:
  1. if($submit) //If submit is hit{    mail("youremailaddress@whatever.com", "$subject", "$email", "$comments");}?>

And here is the form for the sending this file. Its fairly simple and easy to understand if you know HTML. Now here is the processing in English:

  1. If submit is not hit, then display the form.
  2. Have the send button.

Here it is in PHP:

PHP:
  1. {?&gt;<form method="post" action="comments.php">     //comments.php = the name of this script    E-Mail: <input type="TEXT" name="email" size="60" /> //their email address    Subject: <input type="TEXT" name="subject" size="60" /> //subject    Comments: <textarea name="comments" rows="10" cols="30"></textarea> //comments    <input type="submit" name="submit" value="submit" />    </form>

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in