How To Create Simple PHP Contact Form Script

Share:

Tutorial : How To Create Simple PHP Contact Form Script. Features contact form is one of features that must be present in a web or blog. Because the features of this contact form can be used as a convenient way to establish communication between the admin site with their visitors. Through a contact form, visitors can easily send a message to the site admin.
Tutorial : How To Create Simple PHP Contact Form Script Tutorial : How To Create Simple PHP Contact Form Script
Below I will explain how to create a simple contact form using php script. So you don’t need to use the services of a third party, other that this simple php contact form can your develop itself according to your desire.

Download Now How To Create Simple PHP Contact Form Script - How To Create Simple PHP Contact Form Script

Tutorial : How To Create Simple PHP Contact Form Script

Here are instructions on how to create a simple contact form with php script

1. Creating a Contact Form with HTML

The first step is to create a contact form to write a message using html. In here, I will give the name of the file the contact form with contact-form.html, the following script to create a contact form.
contact-form.html

<style type="text/css">
<!--
.style2 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
}
.style3 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
-->
</style>
<form name="form1" method="post" action="php-contact-form-script.php">
  <div align="center">
    <p class="style3">Simple Contacts Form </p>
    <table width="40%" border="0">
      <tr>
        <td valign="top" class="style2">Email</td>
        <td valign="top" class="style2">:</td>
        <td valign="top" class="style2"><label>
          <input name="your_email" type="text" id="your_email" size="30">
        </label></td>
      </tr>
      <tr>
	  	<td valign="top" class="style2">To</td>
        <td valign="top" class="style2">:</td>
        <td valign="top" class="style2">
        <input type="radio" name="choose" value="1">Admin
		<input type="radio" name="choose" value="2">Send a Article
        <input type="radio" name="choose" value="3">Advertiser</td>
      </tr>
	  <tr>
        <td width="26%" valign="top"><span class="style2">Subject </span></td>
        <td width="2%" valign="top" class="style2">:</td>
        <td width="72%" valign="top" class="style2"><label>
          <input name="subject" type="text" id="subject" size="30">
        </label></td>
      </tr>
      <tr>
        <td valign="top" class="style2">Messages </td>
        <td valign="top" class="style2">:</td>
        <td valign="top" class="style2"><label>
          <textarea name="messages" cols="35" rows="5" id="messages"></textarea>
        </label></td>
      </tr>
      <tr>
        <td valign="top" class="style2">&nbsp;</td>
        <td valign="top" class="style2">&nbsp;</td>
        <td valign="top" class="style2"><label>
          <input name="sending" type="submit" id="sending" value="Sending">
          <input name="cancel" type="reset" id="cancel" value="Batal">
        </label></td>
      </tr>
    </table>
</div></form>

2. Make Command Send A Message with PHP Script

A contact form file that was created to run the command, sending messages, for the purpose of the site admin email. We need a php script, this php script will simultaneously inform us that this message has been successfully sent or not. File format for the php script is .php and complete the script is :
php-contact-form-script.php

<?php
$your_email=$_POST['your_email'];
$choose=$_POST['choose'];
$pil=$choose;
$subject=$_POST['subject'];
$messages=$_POST['messages'];
echo '<font face="Verdana, Arial, Helvetica, sans-serif" size="2">'; 
if ($pil==1){
$email_to = "admin@yourmail.com";
}elseif ($pil==2){
$email_to ="write@yourmail.com";
}elseif ($pil==3){
$email_to ="ads@@yourmail.com";
}
$sent=mail($email_to,$subject,$messages, "From: ".$your_email."nContent-Type: text/html; charset=iso-8859-1");
if ($sent){
$messages = str_replace("rn","<br>", $messages);
echo("Your message has been successfully sent to <b>$email_to</b><br><br>");
echo("<b>This is your messages :</b><br>$messages");
}else{ 
echo ("Sorry, your message was not successfully sent and please repeat back to send a message using the contact form");
} 
?>

Please try the contact form on your web server and make sure the PHP Mail() Function can be run because when PHP Mail() Function is disable you will not be successfully send a message using the contact form php script.
Good luck and thank you for reading Tutorial : How To Create Simple PHP Contact Form Script

[Tutorial.World.Edu]

2 thoughts on “How To Create Simple PHP Contact Form Script

Leave a Reply

Your email address will not be published. Required fields are marked *