Form to mail
Would you like to get on your email all the information included in a form?- 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.
- Second: 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.
No comments:
Post a Comment