PHP is open source scripting language. It\'s widely used to develop web applications.  Home Web Programming PHP Create a contact page with html and php

Create a contact page with html and php


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:

bg.gif
index.php
send.php

Download: here

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

<html>
<head>
<title>Contact</title>
</head>
<body>
<body background="bg.gif">
<form action="send.php" method="post">
<pre>
<center>
<br>
<br>
E-Mail
<input type="text" name="email" value=""><br>
Name
<input type="text" name="name" value=""><br>
Surname
<input type="text" name="surname" value=""><br>
Subject
<input type="text" name="subject" value=""><br>
Message<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">
</form>
</body>
</html>

Save this like index.php

2. Here we write the send.php page

<?php
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 = 'piticstyle@yahoo.com'; // change e-mail adress
$send_date = date('d-m-Y H:i:s');
$subject = $_POST['subject'];
$message = '
<html>
<head>
<title>Contact</title>
</head>
<body>
<p><tt>Send Date: '.$send_date.' </tt></p>
<table>
<tr>
<td><tt> Name: '.$_POST['name'].' </tt></td>
</tr>
<tr>
<td><tt> Surname: '.$_POST['surname'].' </tt></td>
</tr>
<tr>
<td><tt> E-Mail: <a href="mailto:'.$_POST['email'].'" mce_href="mailto:'.$_POST['email'].'">'.$_POST['email'].'</a> </tt></td>
</tr>
<tr>
<td><tt> Message: <br><br> '.$_POST['message'].' </tt></td>
</tr>
</table>
</body>
</html>';
$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:

Yeahost.com

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



Author's URL: PiticStyle
PHP is open source scripting language. It\'s widely used to develop web applications. More PHP Tutorials: Featured Materials | Fresh Materials | More PHP Tutorials at LearnPHP.org

Reader's comments
comments gsagsag December 21, 2011 says:
szvsagsaf
Reply
comments sopyan October 30, 2011 says:
Reduction moncler coats, moncler clothes, moncler jacket, moncler large Office 2010 Product Key downward cover chinese suppliers copy moncler along coat moncler coat wholesaler exporters www.office2010key.biz dropshippers moncler from suppliers vendors. Browse Windows 7 Ultimate Key, moncler coats, moncler clothes, Ugg Australia Outlet little one's spencer at discount, you'll find that discounted moncler
Reply
comments Raja Bushanam June 22, 2011 says:
I have problem to install php in my system please tell me the procedure
Reply
comments cesar April 29, 2011 says:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/25/d365208919/htdocs/contact-form/send.php on line 2
Reply
comments Cesar April 29, 2011 says:
How can I solve this please?
Reply
comments brian February 11, 2011 says:
u put it on the html
Reply
comments Error January 15, 2011 says:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/r/e/d/redseade/html/flyph/send.php on line 2
Reply
comments needhelp October 27, 2010 says:
how can i make the code so that when somebody fill out the form, a reply message will be sent to their input e-mail.
Reply
comments Jay September 02, 2010 says:
-----------------------------------------------------------------------------------------------------

Adam August 02, 2010 says:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /send.php on line 2

why?

Read more: http://www.webdesign.org/web-programming/php/create-a-contact-page-with-html-and-php.15099.html#ixzz0yPrwQ4vE
-----------------------------------------------------------------------------------------------------

Because
in your php you must enter in a missing "

example:

($_POST['name'] == ") ||

sho

Reply
comments Sidhant March 05, 2011 says:
cOULD U PLZ ELLABORATE.......able to understand...
Reply
comments Sidhant March 05, 2011 says:
sidhant16agarwal@gmail.com
Reply
comments Girish August 26, 2010 says:
thank u vry mch...
Reply
comments Adam August 02, 2010 says:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /send.php on line 2

why?

Reply
comments big smoke July 30, 2010 says:
thanx....
Reply
comments matthew July 21, 2010 says:
I'm using webs how would i add this on webs?
Reply
Add comments to "Create a contact page with html and php"

Captcha