| Home > Computer & I'net > Email - Making Forms... |
|
|
||||||||||||||
|
|
||||||||||||||
|
|||||||||||||||
Email - Making Forms | |
form.html <html> <head> <title> My Test Form </title> </head> <body> Send us an comment about our site!<br /> <form action="process.php" method="post"> Subject for email : <input type="text" name="subject"><br /> Visitor email : <input type="text" name="from"><br /> Message : <textarea name="message" rows="3" cols="40"></textarea><br /> <input type="submit" value="Send the info"> <input type="reset" value="Clear the form"> </form> </body> </html> The ACTION tells the form to send the information gathered to the processing script when the SUBMIT button is clicked. The NAME values will become variables when they reach the processing script. The input information becomes the variable values. process.php <?php
$to = "yourplace@somewhere.com"; $headers = "From: " . $from . " "; $headers .= "Reply-To: " . $from . " "; $headers .= "Return-Path: " . $from . " "; if ( mail($to,$subject,$message,$headers) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> The $header area has been modified a bit from the previous examples. Since the form is gathering information from the visitor, this will enter the info and add the correct start and ending parts for the 4th mail variable. ----------------- Article by David Stanley. Visit his site http://www.htmlite.com. Reprinted with permission. | |
| Articles |
•Auto & Trucks•Business•Computer & I'net·General·Apache·CSS·Database·Hardware·HTML·Javascript&DHTML·Linux·MySQL·Operating System·Perl / CGIPHP·Programming·Publishing·Search Engines·Software Problems·SSI·Tips & Tricks·Utilities·Web Design•Family•Food & Drink•Gardening•Health•Other•Pets•Psychology•Spiritual•Travel•Women |
| Calculators |
|