HTML Form in PHP

HTML FORM in PHP tutorial will explain you How to get a value typed in HTML form in PHP script? with example.

As PHP is a server side scripting language user interaction can only occur when we send some information to the server, in turn the server processes our request and sends the requested page, for that we need to post (Send) data to the server.

Using HTML FORM we can pass data from one page to another. The PHP $_GET and $_POST variables are used to retrieve information from form.

PHP Form Handling

Typically a PHP script wants to get the values, user typed into the HTML FORM.

Example on HTML form:


When a user fills out the form above and click on the submit button, the form data is sent to a PHP file, called “FormProcess.php”:

This is Form action

What we have done in the above html page is that we have created a HTML FORM that is going to send data to the PHP file FormProcess.php this file will be called by the web-server and processed after processing it will be sent to the browser.

The output will be:

HTML Form Validation

Whenever possible user input validation should be performed on browser by using client script. Browser Validation will reduce server load.

When the form accesses a database, we should always use server side validation. Posting form to itself is a good way to server side validation. If there is input error, error message will be displayed on same page.

Previous articlePHP Functions
Next articlePHP GET Variable
I am a young Information Systems Security Engineer(CEH). I had started with penetration testing when i am 17 years old. It all started with Kali linux and Metasploit.In free time i will play with Security holes/Bug bounty/Pentesting and Hacking !!!