- Right click on the below file and choose "Save Target As…" to save it to your computer.
- Rename the file so that it ends in ".php" instead of ".txt". The first part of the filename can be whatever you want, but the file extension must be .php for the form to work.
- The example email form has two input boxes (name and email) and one text area (comments). If you don't want any more fields, then skip to step something.
- To add an input box, add the following code after "<table>" and before "</table>". Change all places that say "email".
<tr>
<td><label for="email">Email</label></td>
<td><input type="text" id="email" name="email"></td>
</tr> - To add a drop down list, add the following code after "<table>" and before "</table>". Change all places that say "gender". Change "Male" and "Female" to whatever you want the choices to be.To add another option, add the following code after the "Female" line and before the "</select>" line and change "Unspecified" to the option name.
<tr>
<td><label for="gender">Gender</label></td>
<td>
<select id="gender" name="gender">
<option>Male</option>
<option>Female</option>
</select>
</td>
</tr><option>Unspecified</option>
- To add a text area, add the following code after "<table>" and before "</table>". Change all places that say "comments".
<tr>
<td><label for="comments">Comments</label></td>
<td><textarea id="comments" name="comments"></textarea></td>
</tr> - To change what the "Submit" button says, edit the following part of the code that is in bold.
<td><input type="submit" name="submit" value="Submit"></td>
- Change "yourname@example.com" to your email address (line 7). This must stay in quotes.
- Change "Email Form Comments" to what you want the subject of the email to be (line 8). This must stay in quotes.
- Edit the following part of the code so that it corresponds with the fields you added to the form. You will want to change the places that say "name", "email", and "comments" if you changed the names of these fields.
$message = "Name: " . $name . "\\n";
$message .= "Email: " . $email . "\\n";
$message .= "Comments: ". $comments; - If you have more than three fields, add this line after the "comments" line, and change both places that say "gender" to the name of your field.
$message .= "Gender: " . $gender . "\\n";
Email Form Examples
Note: This form does not actually send your comments.