Share Variables between PHP files [closed]

0

Good morning, I would like to share the data typed in an input between 2 files. In the Form action I use the validation file, to check the login and password, but I wanted the data entered in these fields also to another file, so I can show the user's name, according to their login, so I would need to pass the variable $ login to the second file:

$login = $_POST['login'];

in the two files, the 1st for verification and the 2nd for the DB. Thank you in advance.

    
asked by anonymous 09.10.2018 / 14:17

1 answer

1

On every page you need to declare / use a SESSION , you must start a session at the beginning of such a page, for this you need to use the following command: session_start() , once logged in, you can assign values as $_SESSION["login"] = $login .

Now on the second page you just have to start the session again with session_start() and then call the value you want echo $_SESSION["login"] .

You can find more information about sessions Here

    
10.10.2018 / 19:47