Post method in Php

Post method in Php

In this article following thing should be studied:

  • What methods are used to gather informtion?
  • What is POST method?
  • How to use POST method.
  • Important NOTE.


There are two methods of getting user information that he provided in the form. And these methods are as follows:

  1. _GET
  2. _POST

     In this Article you will be studying how to use the POST method for storing the values that user gives in the particular form.


POST Method:

What is POST method?

When the user fills the form and clicks the submit button, the form data is sent for processing to a PHP file named "welcome.php". The form data is processed with the HTTP POST method.

Why to use POST method?

          This method is used for storing or updating data. By this method we can store images and files also which we were unable to store in the GET method. POST method is used to send sensitive data.

How to use POST method?

There are two things that should be in your mind while using this method.
  1. Set the method of form as "post".
  2. Use _POST[ ]  in the Php to store the form values in the variables.

Set method of form as POST:

             Its a very easy code to be done in the HTML while initializing a form.
     





             <form method = "post"></form>

Use of _POST[ ] in Php:

             Its a case sensitive because in this step you are declaring variables and storing the input by user in these variables. You must have to mention that by what method you are gathering the information.

Check Condition:

  • First of all you have to put a check in php that if the user has clicked the submit button or not.
  • And in this check condition you have to declare the $_POST method.




Storing Values:

  • Declare the variables in which data should be stored  (i.e $post_value).
  • Than store the values by giving input names (from HTML form input names) and do this by $_POST[ ] method.



Input Names:

              These are the names are from the form inputs in which user is storing the data.





NOTE:

     The inputs user is providing should not be shown in the URL bar because of case sensitive.

And to know how to insert these values in the Database Click the Following Link:




Related Post: