One of the key things to learn if you are just starting to learn PHP is how to handle forms. This process seems to stump new developers to PHP but this shouldn’t be a big obstacle.
PHP has many features that allow for simple data gathering and easy form. processing. In this tutorial, I will discuss how to use the action method of the form. and show you how to create a simple form. that you can use on your site that will allow your visitors to contact you via email.
This will require the creation of two items: the HTML form. and the PHP script. that will handle it. The tutorial includes a snippet of PHP and HTML source code that you can use as a starter for your form.
Setting up the HTML
Here is my simple HTML contact form.:
CODE:
Name:
Email:
Comments:
When you look at this HTML contact form. you may notice that most HTML form. elements have a name, id and value. The id attribute is not required but if you are doing any JavaScript. or have CSS styles you may need to use them. The name property is what we will use to get the values in PHP.
There are two ways to send form. data, GET and POST. For the purposes of this article, I will be sending this data via POST, as you can see in the