::Online Microsoft Office,Web ,Graphic and many more Tutorials
Create a PHP contact form
Creating a PHP contact form isn’t that hard, follow this tutorial and you will soon have your own contact form for your website or blog.
There are two parts to this, the form itself which will be inserted into a web page and an external PHP file which handles the data and sends it to the email address. Please note that you will need PHP installed on your web server in order for this to work. Most web servers do have PHP installed but its worth checking with your web hoster before spending your time on this.
We are going to have 4 fields which are 3 textboxes and 1 text area. The fields will be Name, Email, Subject and the text area will be for the user to add their message.
To create this form, copy and paste the following code into your webpage’s code anywhere between the <body> and </body> tags.
Notice that the form action is set to contact.php, this will be the file that handles the data and sends it to your email account. So we are now going to create the contact.php page.
If you take a look at the code above you will notice that it defines some actions first of all, so for example it defines your email address as $to and the subject of the email as $subject. Now you will also notice a $_POST["title"]; this collects the data from the previous page in the field stated in the speech marks (in this case title). The name of the $_POST is the name of the form item.
Finally it mails the email to you by calling the $to (your email address), the $subject (title of the email), $messagesent (the message) and $headers which is the recipients name/email.