Today’s post, I would like to share with you a very simple HTML Contact Form using the PHP function. If you wouldn’t use a CMS for your website, then this article for you. So let’s start, First, I would like to create a simple HTML contact form. Please remember, This tutorial, Only HTML And PHP but wouldn’t connect this form with MYSQL databases.

Basic HTML Form

You should add the following an HTML code on your website before close the body tag. Or you can create HTML contact form template e.g: contact.html I have used an HTML table tag, so I would like to recommend using the Twitter Bootstrap.

<form name="contactform" method="post" action="send_form_email.php">
<table width="450px">
<tr>
 <td valign="top">
  <label for="first_name">First Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="first_name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top"">
  <label for="last_name">Last Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="last_name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email">Email Address *</label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="telephone">Telephone Number</label>
 </td>
 <td valign="top">
  <input  type="text" name="telephone" maxlength="30" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="comments">Comments *</label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
 </td>
</tr>
<tr>
 <td colspan="2" style="text-align:center">
  <input type="submit" value="Submit"><a href="example.com/email_form.php">Email Form</a>
 </td>
</tr>
</table>
</form>

In the below, the HTML contact form example. You can make this form more beautiful using CSS but if you have a great experience with CSS.
Create A Simple Contact Form In HTML And PHP

The PHP Code which captures and Emails your website form

Below PHP code is a very basic function. The PHP function will capture the form fields specified in the HTML form raised (first_name, last_name, email, tel, and comments) and the fields are then sent off to your email address in plain text.

Create a PHP template, Look like send_form_email.php and add the following code. Also, You should edit, $email_to, $email_subject, you can add your business eamil address and your subject.

Copy to Clipboard

After adding the code save the code and go back HTML template.

Your HTML and PHP simple Contact form is done. I honestly believe, this form working perfectly. So, Still, if you have any questions, please comment below and if you enjoy this article, then please share it with your friends.

Topics