Share this post! | Vote this! |
|
Many web sites are opting to use a contact form to allow its visitors to communicate. This is larger due to the prevalence of spam bots which harvest email addresses from web sites. In this tutorial, we’re going to build a simple contact form in PHP.
This is going to be a pretty simple contact form. We’ll be using a single PHP file to display the form and to process it. This simplifies things quite a bit. Ready? Let’s get started.
Step One: Creating the Form
The first step is to create some HTML markup for our form. For this tutorial, we’re going to ask the user to give us their email address, name, a subject line and a message. Create a file named contact.php or whatever you want to call your form. Using a PHP file for this allows us to add PHP code to the file. In the later steps, we’ll be adding the code to process this form so that one file handles the entire process. Additionally, we’re going to use the $_SERVER variable to get the name of the current file. We will use that to supply the action parameter to our form tag in order to make sure the form gets submitted to the same page that generated it. Here is our initial markup:More...
0 comments:
Post a Comment