Forms

  • PHP is faster and Simpler.

  • PHP is very efficient at passing data because the developers made a it very easy when they choose suitable design decision.

  • PHP automatically, but invisibly, assigns the variables for you on the new page when you submit a data set using GET or POST.

  • If you forget to do so or make a mistake, the information will not be available to the processing agent.


GET Method

  • The GET method suse to pass arguments from one page to another of next page as part of the Uniform Resource Indicator(URI).

  • GET appends the indicated variable name(s) and value(s) to the URL designated in the ACTION attribute with a question mark separator and submits the whole thing to the processing agent.

    • When the user clicks the Submit button, the browser arrange in order,with no spaces between the elements: The URL in quotes after the word ACTION (http://localhost/test.php)

    • A question mark (?) denoting that the following characters compose a GET string.

    • A variable NAME, an equal sign, and the matching VALUE (name=ABCD).

    • An ampersand (&) and the next NAME-VALUE pair (Submit=Select),further name-value pairs separated by ampersands ,it can be added as many times as the server querystring(length of string limit allows).
Example :
<form action="test.php" method="get">
Name: <input type="text" name="name">
City: <input type="text" name="city">
<input type="submit">
</form>
Note :
When the user clicks the "Submit" button, the URL sent to the server something like this:
 http://www.tkhts.com/First/test.php?name=TechKnow&city=Delhi
						
DrawBacks :
  • The GET method is secure for logins because the username and password are fully visible onscreen as well as stored in the client browser's memory as a visited page.

  • Every GET submission is recorded in the Web server log, data set included.

  • Because the GET method assigns data to a server environment variable, the length of the URL is limited.


POST Method

  • POST method is used for form submission today, particularly in nonidempotent usages, such as adding information to a database.

  • The form data set is included in the body of the form when it is forwarded to the processing agent.

  • It does no visible change to the URL will result according to the different data submitted.
Example :
<form action="test.php" method="post">
Name: <input type="text" name="name">
City: <input type="text" name="city">
<input type="submit">
</form>
Note :
When the user clicks the "Submit" button, the URL sent to the server something like this:
http://www.tkhts.com/First/test.php