Generate Php Form for mailing

 In this tutorial explain about 'How make mail form in Php?'. First of all you need a form, as for example the one in the table:

Form.html 

<FORM ACTION="formtomail.php" METHOD=post>

<!-- Your fields here -->

<INPUT TYPE=submit value="Submit">
</FORM> 

The Form Action must be directed to the PHP script bellow. you need the php script (copy the information in the table to a text file and save the file as "formtomail.php" in your server).

Formtomail.php 
<?
if ($_POST){
      // posted information is added to variable message
      $message="";
      foreach ($_POST as $formfieldname => $formfieldvalue){
            $message.="$formfieldname \n $formfieldvalue\n\n";     //
      }
     // send email with information from the form to
      mail("webmaster@mysite.com","Form to Mail", $message,"From: <webmaster@mysite.com>\nContent-Type: text/plain");
      print "The information has been send to webmaster";
}else{
      print "No information has been posted";
}
 
?> 

You need to customize the script: substitute red text in the script by your email. This scripts assumes you have no restrictions to use mail commnad.
Share:

No comments:

Post a Comment