PHP Pass variable to next page

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.

<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

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...