I have 3 files:
login.htmllogin_check.phpwelcome.php
In login.html when the username and password is entered and submit button is clicked login_check.php checks whether the username entry is in the database on the basis of $_POST['username'] and some SQL query. Now I have put the following code at the bottom of login_check.php
login_check.php:
header('Location:welcome.php')
But I want to pass $_POST['username'] from login_check.php to welcome.php so that I can make use of $_POST['username'] in my welcome page. Is there any way by which I can pass an argument like in the above case?
Use
sessioninstead because you would be showing the user’s name everytime on the welcome page no matter which page you land at welcome page.You can set the session on login_check page like:
Now on the welcome page, you can show username like: