Skip to content Skip to sidebar Skip to footer

How To Pass Variables Between 2 Php Files?

Solution 2:

code is here,

<?phpif($_REQUEST['click'] == 1)
    {
        echo"One was clicked.";
    }
    elseif($_REQUEST['click'] == 2)
    {
        echo"Two was clicked.";
    }

?><html><body><ahref="two.php?click=1">Click here for 1.</a><ahref="two.php?click=2">Click here for 2.</a></body></html>

Solution 3:

You can pass variables by using GET or POST method.

Here is simple GET (query string) method.

main.php :

<html><body><ahref="two.php?btn=One">Click here for 1.</a><ahref="two.php?btn=Two">Click here for 2.</a></body></html>

two.php :

<?phpif(!empty($_GET['btn'])) {
    echo$_GET['btn'] . " was clicked";
}
?>

Solution 4:

Post a Comment for "How To Pass Variables Between 2 Php Files?"