FORM HANDLING IN PHP - DesiNewsIndia

Welcome to World of News

Breaking

Akshay

Home Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Monday, July 9, 2018

FORM HANDLING IN PHP


Forms are used to get input from the user and submit it to the web server for processing. The diagram below illustrates the form handling process.


A form is an HTML tag that contains graphical user interface items such as input box, check boxes radio buttons etc.
The form is defined using the <form>...</form> tags and GUI items are defined using form elements such as input.

When and why we are using forms?

  •   Forms come in handy when developing flexible and dynamic applications that accept user   input.
  •  Forms can be used to edit already existing data from the database 
Create a form
 
We will use HTML tags to create a form. Below is the minimal list of things you need to create a form.
  •  Opening and closing form tags <form>…</form>
  •  Form submission type POST or GET
  • Submission URL that will process the submitted data
  • Input fields such as input boxes, text areas, buttons,checkboxes etc. 







HERE,
  •  <form…>…</form> are the opening and closing form tags
  •  action="registration_form.php" method="POST"> specifies the destination URL and the submission type.
  •  First/Last name: are labels for the input boxes
  •  <input type=”text”…> are input box tags
  •  <br> is the new line tag
  • <input type="hidden" name="form_submitted" value="1"/> is a hidden value that is used to check whether the form has been submitted or not
  •  <input type="submit" value="Submit"> is the button that when clicked submits the form to the server for processing 

POST Method
 
The POST method transfers information via HTTP headers. The information is encoded as described in case of GET method and put into a header called QUERY_STRING.
  • The POST method does not have any restriction on data size to be sent.
  •  The POST method can be used to send ASCII as well as binary data.
  • The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.
  •  The PHP provides $_POST associative array to access all the sent information using POST method. 



 Get Method
 
The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character.

http://www.test.com/index.htm?name1=value1&name2=value2
  •  The GET method produces a long string that appears in your server logs, in the browser's Location: box.
  •  The GET method is restricted to send up to 1024 characters only.
  •  Never use GET method if you have password or other sensitive information to be sent to the server.
  •  GET can't be used to send binary data, like images or word documents, to the server.
  •  The data sent by GET method can be accessed using QUERY_STRING environment variable.
  •  The PHP provides $_GET associative array to access all the sent information using GET method.







 


  

REQUEST Method
 
The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE. We will discuss $_COOKIE variable when we will explain about cookies. The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.



 


  

No comments:

Post a Comment

Post Bottom Ad

Responsive Ads Here

Pages