user6568979 user6568979 - 2 months ago 19
PHP Question

Php button handling

I have created a button, now i want to change a variable's value and pass into anothor php file when the button is pressed. I have tried to find some infirmation from google but couldn't find something useful. Can anyone help me to do this?

MKB MKB
Answer

Lets suppose your button is a link such that

<a href="?set=1">Click here</a>

On click of this button when page would load get the query string parameter like below:

<?php
$var = "someValue";
if(isset($_GET['set']) && $_GET['set'] == true){
  $var = "ChangedValue";
  header("Location:abc.php?val="$var);
}
?>

and get the val in the other file.

Comments