In every projects we have to pass values from one page to another. In php there are 3 methods available commonly ( More methods may be available ).
Post is one of the common and safest method used. In this method, values are passed to the next page as hidden values. For using this method, first we need to redirect to the next page by post method.
<form method="post" action="second_page_name.php" >
<input type="hidden" name="name_of_value" value=" value_to_transfer ">
Now the page will be redirected to
second_page_name.php and the
value_to_transfer will be available in the page on a post variable
Now let us see how we can retrieve the value.
Declare a variable to store the value. Here the variable is say
$temp is holding the value which we passed.
Get is the second method widely used. Though it is common, it is not safe to use. In this method, the value is passed along with url. In the second page, we extract the value from the url.
Why this method is not safe is, every one can see the values passed. This will help hackers to intrude into the actions and hack the website.
Now lets see how can we pass a value through url
second_page.php is the second page where the value should be passed.
email@example.com is the value to be passed.
After the name of the second page, put a
?. After that we assign a name (here
=hen place the value.
Now lets see how can we get the value in the second page.
$temp is holding the value
As everyone knows session is a feature of web technology. Let’s see how can we use session to transmit value.
Now the value got transmitted.
Now to retrieve the value.
$temp is holding the value.