Hi, I think you like my tutorial , Today we make a contact page with php .It has many way to create a contact page . We choose the easy way .So don’t lost our time to talk
Why need a contact page ?
Contact page is very important thing for Website/blog . because It send the visitor feedback to the site admisitrator.So the administrator be aware of problem and solve this .
By the way , Now we create a html page and a form that’s has 2 text box , 1 textarea and 2 button .
<head><title>Easily create php contact page</title></head>
<form action=”mail.php” method=”POST”>
<p>Name</p> <input type=”text” name=”name”>
<p>Email</p> <input type=”text” name=”email”>
<p>Message</p><textarea name=”message” rows=”8″ cols=”25″></textarea><br />
<input type=”submit” value=”Send”><input type=”reset” value=”Clear”>
Save it named feedback.html or index.html
Note: Look’s carefully , you see name = “name” , name= “email” , name=”message” . that’s name call the php page’s name . form action=”mail.php” . Here mail.php is the name of php page . method =”post” for url security .
Now we create a php page like look’s below …
Save it named mail.php
- $name = $_POST['name']; = it collect name from html page
- $email = $_POST['email']; = it collect email from html page
- $message = $_POST['message']; = collect message from html page
- $formcontent variable contain 2 variable that indicate where the message from
- $recipient = here put your mail address
- $subject variable is show the recipient mail subject
If all info is correct , the message your mail by the code [ mail($recipient, $subject, $formcontent, $mailheader) ] and show “Thank You!, your message send successfully “
Or all info is incorrect show error message by the code [die("Error ]
After that , we put those file (feedback.html and mail.php ) in folder . Rename to the folder is contact. Now we upload folder to root or other directory. After upload go to http://yoursite.com/contact/ . Now the form is ready for sending mail .try it ….
1. wrote the php code carefully
2. If mail not send you sure that your server is enable for mail function .
If you fetch any problem about that please comment
Demo Download Now