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> <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:
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.


Reply
Reply
Reply
Reply
Reply
Reply
Reply
Reply
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
Reply
Reply
Reply
why?
Reply
Reply
Reply