HTML & PHP - Make a funtioning contact form

Today, i'll make tutorial how to make a funtioning contact form. You can view sample by viewing my blog contact page.

First : The HTML 5 code.

<form action="the-php-file-url-here" enctype="multipart/form-data" id="myForm" method="post">
<legend>Personal information</legend>
<label for="name">Name</label>
<input id="name" maxlength="50" name="name" size="50" type="text" value="" />
<label for="email">E-mail</label>
<input id="email" maxlength="50" name="email" size="50" type="text" value="" />
<label for="website">Website</label>
<input id="website" maxlength="50" name="website" size="50" type="text" value="" /></fieldset>

<label for="subject">Subject</label>
<input id="subject" maxlength="50" name="subject" size="50" type="text" value="" />
<label for="message">Yout Message</label>
<textarea cols="50" id="message" name="message" rows="5"></textarea></fieldset>

<input class="button" name="send" type="submit" value="Send Message" /><input class="button" name="reset" type="reset" value="Clear From" /></fieldset>

Change the 'the-php-file-url-here' to your php file url. Embed this code to your contact page.

Second : The PHP file.

$name = $_post['name'];
$email = $_
$website = $_
$subject = $_
$remarks = $_
$today = date("l, F d, Y h:i" ,time());
$to = "your-email-address-here";
$title = "My blog feedback";
$message = $name;
$message .= "<br />";
$message .= $email;
$message .= "<br />";
$message .= $website;
$message .= "<br />";
$message .= $subject;
$message .= "<br />";

$message .= $today;
$message .= "<br />";
$message .= "<br />";
$message .= $remarks;
/* headers */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: <" . $email .">\r\n";
$headers .= "X-Mailer: PHP / ".phpversion()."\r\n";

$sent = mail ($to, $title, $message, $headers);
if($sent) {

//Where to redirect user if the message sent out
else {

//Where to redirect user if send failed.

Upload this file to a web hosting that support PHP script. Take the url and change 'the-php-file-url-here'. Make sure you change all the text in cyan color to yours.

Have a try. :D

Write by Arafa Daming