Pass a variable value from one php page to another

瘦欲@ 提交于 2019-12-06 06:34:55

Use session variables.

First of all every page you want to use sessions on needs to have the function session_start(); declared at the top of every page. You then can use the session superglobal to store things.

Pg1.php:
    <?php
    session_start();
    $_SESSION['variable_name'] = 'string';
    ?>

Pg2.php:
    <?php
    session_start();
    echo $_SESSION['variable_name'];
    ?>
Pg2.php will show: some string
ChunkyBaconPlz

Either POST your value so your second page can retrieve it in the $_POST array, or include it in the URL path so your second page can $_GET it.

Without more info, we can't really help you any more than that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!