Form Handling in php

Forms are use to get user information and then process these information. Without forms no one can imagine to built a dynamic website that offers different functionalities to the user.

Where forms are used in the website?

Forms can be used anywhere in the website it depends up on you. For example if you want from user to register then you have to use form, if u want from user to signin then u have to use form, etc.

How to access form values after form submit the form?

There are two main attributes of form elements, one is method and other one is action.

method is the attribute that specify how form data must be transfered from this page to the page define in action attribute of the form.

There are two instances(values) of method attribute, one is get and other one is post

When to use get and when to use post?

When u want to show the form elements in the addressbar of the browser or when you want to submit query string then method=get is used , suppose we have a form containing two fields one is username and other is password, if we use method=get then all information will be displayed to the addressbar of the browser like below

for example:-http://localhost/dest-pae.php?name=Adeel&&password=987654

so hence one thing is also proved that u cannou use get method whenever you want to transfer secure data like password so then u have to use method=post because no information is display to the addressbar if we use method=post

How to get form data?

To get form data in next page or in same page just make sure what is the value of attribute method, if method=get then use $_GET to get the form elements and if method=post then use the $_POST




Also view the images to see full demonstration of form handling in php