1. Computing

A Practical PHP Form to Mail

By

1 of 4

The HTML Form
You have probably already read about the mail function, and now want to build a more complex form to use on your site. Let's start with the HTML for the web form.

 

 <html><body><font face=Arial size=2> 
 <form method="post" action="contact.php"> 
 <table bgcolor=#ffffcc align=center> 
 <tr><td colspan=2><strong>Contact us using this form:</strong></td></tr> 
 <tr><td>Department:</td><td><select name="sendto"> <option value="info@mycompany.com">General</option> <option value="support@mycompany.com">Support</option> <option value="sales@mycompany.com">Sales</option> </select></td></tr> 
 <tr><td><font color=red>*</font> Name:</td><td><input size=25 name="Name"></td></tr> 
 <tr><td><font color=red>*</font> Email:</td><td><input size=25 name="Email"></td></tr> 
 <tr><td>Company:</td><td><input size=25 name="Company"></td></tr> 
 <tr><td>Phone:</td><td><input size=25 name="Phone"></td></tr> 
 <tr><td>Subscribe to<br> mailing list:</td><td><input type="radio" name="list" value="No"> No Thanks<br> <input type="radio" name="list" value="Yes" checked> Yes, keep me informed<br></td></tr> 
 <tr><td colspan=2>Message:</td></tr> 
 <tr><td colspan=2 align=center><textarea name="Message" rows=5 cols=35></textarea></td></tr> 
 <tr><td colspan=2 align=center><input type=submit name="send" value="Submit"></td></tr> 
 <tr><td colspan=2 align=center><small>A <font color=red>*</font> indicates a field is required</small></td></tr> 
 </table> 
 </form> 
 </body> 
 </html> 

 

Related Video
Basic PHP Syntax
Using PHP With HTML

©2014 About.com. All rights reserved.