Saturday, 15 December 2012

PHP POST Function

The $_POST Function

This function is used to collect data from html forms sent with post method. Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send. This post method is more security compare get method. Below simple program will explain this breifly.

Example:
<form action="view.php" method="post">
Article: <input type="text" name="article" />
Price: <input type="text" name="price" />
<input type="submit" />
</form>

When the user clicks the "Submit" button, the form values will be sent to server. but the senting values cant view with URL.When you click the submit button the URL will be look like this

http://www.u3schools.com/view.php

Now you can use $_GET function on view.php page and get the form values. Form fields will automatically be the keys in the $_GET array.

Article name  <?php echo $_POST["article"]; ?>.<br />
Article price <?php echo $_POST["price"]; ?> INR(Indian rupees)

The output of above code:
Article name  Nokia1200
Article price 1540 INR(Indian rupees)

Advantage of post method:
=> The POST method is invisible to others
=> It has no limits on the amount of information to send.

0 comments:

Post a Comment