How do I share a PHP variable between multiple pages?

后端 未结 5 692
离开以前
离开以前 2020-12-20 09:36

The idea/goal:

I have a username and password inside a text file on my computer. The form on the index page allows the user to sign in with their us

5条回答
  •  情深已故
    2020-12-20 10:01

    1. Start a php session on each page right after the opening php tag:

      session_start();

    After you determine that the name and password work, and before you do the redirect, add this line:

    $_SESSION['name'] = $name;

    On any subsequent pages, just echo something like this:

    echo "Welcome ".$_SESSION['name'];
    

提交回复
热议问题