Get Our Free Ebook
Beginners Guide to HTML

  Web Programming PHP Create a contact page with html and php

Create a contact page with html and php

PiticStyle PHP Jun 03, 2008

I have made a tutorial about how to install EasyPhp and now i come with an example. Today we learn how to create a Contact Page in HTML and PHP very easy! Download the next files to exercise on them:


Download: here

1. Let's write the index.php / Here we use HTML

<body background="bg.gif">
<form action="send.php" method="post">
<input type="text" name="email" value=""><br>
<input type="text" name="name" value=""><br>
<input type="text" name="surname" value=""><br>
<input type="text" name="subject" value=""><br>
<textarea name="message" cols="60" rows="6"></textarea><br><br>
<input type="submit" name="Send" value="Send"><input type="reset" name="Clear" value="Clear">

Save this like index.php

2. Here we write the send.php page

if(($_POST['email'] == ") || ($_POST['name'] == ") || (is_numeric($_POST['name'])) || ($_POST['surname'] == ") || (is_numeric($_POST['surname'])) || ($_POST['subject'] == ") || ($_POST['message'] == ")) {
echo 'Complete the forms correctly <br>
Click <a href="/img_articles/15099/index.php" mce_href="/img_articles/15099/index.php">here</a> to return on main page.';
} else {
$to = '[email protected]'; // change e-mail adress
$send_date = date('d-m-Y H:i:s');
$subject = $_POST['subject'];
$message = '
<p><tt>Send Date: '.$send_date.' </tt></p>
<td><tt> Name: '.$_POST['name'].' </tt></td>
<td><tt> Surname: '.$_POST['surname'].' </tt></td>
<td><tt> E-Mail: <a href="mailto:'.$_POST['email'].'" mce_href="mailto:'.$_POST['email'].'">'.$_POST['email'].'</a> </tt></td>
<td><tt> Message: <br><br> '.$_POST['message'].' </tt></td>
$headere = "MIME-Version: 1.0rn";
$headere .= "Content-type: text/html; charset=iso-8859-1rn";
$headere .= "From: ".$_POST['name']." ".$_POST['surname']."<".$_POST['email'].">rn";
mail($to, $subject, $message, $headere);
echo 'The message was send';

Save this like send.php

3. Test your contact page:

To test your contact page you need to upload the files on a server. If you dont have your own server & domain name, search on internet websites who give free host with the option to have acces on the ftp. I found a site:

If you don't understand something please write a comment, thank you for your attention and check this tutorial to learn how to install EasyPHP (Php, MySQL, Apache, PhpMyAdmin). Here is the final result.

Create a Contact Page with HTML and PHP

subscribe to newsletter