How to pass a variable to next page using a GET and POST, You can add the variable in the link to the next page This will create a GET variable.
Another way is to include a hidden field in a form that submits to page two:
And then on page two:
<a href="page_2.php?variable=<?php echo $variable_value ?>">Page 2</a>
Another way is to include a hidden field in a form that submits to page two:
<form method="POST" action="page_2.php">
<input type="hidden" name="variable_name" value="variable_value">
<input type="submit">
</form>
And then on page two:
//Using GET
$variable_value = $_GET['variable_name'];
//Using POST
$variable_value = $_POST['variable_name'];
//Using GET, POST or COOKIE
$variable_value = $_REQUEST['variable_name'];
No comments:
Post a Comment