Form of contact with PHP:

In order to create a form of contact for its webpage, best and the simplest thing it is to use code PHP to create and to send the form, since it offers many possibilities and major versatility,to day of today we did not recommendthe use of CGI's that can have been obsolete.

It will have to use the function mail of php.
For it, first that it must do isto create a new file, for example: contactar.php and to raise it the servant.
A pair of notes on php:
- When we put something of PHP within code HTML, it will have to be between the labels:
<? php
- Each line of PHP finishes with the character of semicolon;
- The variables in php have symbol $ ahead.
- The normal texts in PHP are written within quotation marks.
- If we want that a line is only informative (and that does not leave in the page), we will put twoahead to him I sweep: //
- The functions of phpusually needseveral variablesto work correctly:
In particular, function mail, that is the one that is in charge to send post office, needs that we pass 4 variables to him
mail ($emaildestino, $asunto, $cuerpo, $cabeceras);
mail (, Form Web, Hello that so, From: Mysciphone);
This would send a mail to, with the subject Form Web and Mysciphoneas sender
Next we showed the complete code of a hypothetical form that uses PHP:
we suppose that the file is called: contactar.php
<title>Mándanos your comentarios</title>
<meta http-equiv= " Content-Type content= " text/HTML; charset=iso-8859-1 " >
<body text= " #FFFF99 link= " #006060 vlink= " #006060 " >
<? php
if (! $_POST) \ {
//todav íathe visitor has not filled in the form, so we showed it

<form action= " contactar.php method=post>
<tr><td>Nombre: </td><td><input type=text name= " name size=16> </td></tr>
<tr><td>Email: </td><td><input type=text name= " email size=16> </td></tr>
<tr><td>Comentarios: </td><td><textarea name= " coment cols=32 rows=6></textarea></td></tr>
<tr><td></td><td><input type=submit value= " To send " > </td></tr>
<? php
} else \ {
//Estoy receiving the form, I compose the body of the message
$cuerpo = sent Form \ n;
$cuerpo. = Name: . $_POST [name]. \ n;
$cuerpo. = Email: . $_POST [email]. \ n;
$cuerpo. = Commentaries: . $_POST [coment]. \ n;
$cabeceras= " From: . $_POST [email]. \ r \ n. Reply-To: . $_POST [email]. \ r \ n;
//mando the mail
mail (, received Form, $cuerpo, $cabeceras);
//doy thanks for the shipment
I throw Thanks to fill in the form. It has been sent correctly. ;

If the form has but fields (in this case, it only has the name, the email and the commentaries), it would be worked in the same way, adding more lines to the body of the message.