0

My registration.php page sends a user to my login.php page with:

if(mysqli_stmt_execute($stmt)){
// Redirect to login 
header("location: login.php");
} else{
echo "<span style='color: red; margin-left: 5px;'>Something went wrong. Please try again later</span>";
            }

I'd like to figure out how to carry the username & email that they chose on the register.php page over into the input fields on the login.php page

  • 3
    Does this answer your question? [How do I pass data between pages in PHP?](https://stackoverflow.com/questions/1179559/how-do-i-pass-data-between-pages-in-php) – catcon Jul 27 '20 at 05:15

2 Answers2

1

Use this

header("location: login.php?username=".$your_username."&email=".$your_email);
Chilarai
  • 1,842
  • 2
  • 15
  • 33
0

You are able to send your username and email variable with your header function like this

header("location: login.php?username=$user &email=$email");

and on the login.php page you will get them like this:

$username=$_GET['username'];
$email = $_GET['email];

i hope this will help you out.

  • Thank you! The username passed.....the second variable is actually a password, not an email. It didn't pass. I changed "email" to "password"....added the missing ' above, but it didn't pass. Here' my code on the register page: `header("location: login.php?username=$username&password=$password");` Here's my code on the login page: `$username = strip_tags($_GET["username"]); $password = strip_tags($_GET["password"]); $username_err = $password_err = "";` Any idea why it didn't pass? Both the username & the password are in the URL of the login page. – Eric Bebchick Jul 28 '20 at 02:13
  • if its a password i highly recommend you to send it through some secure way like session variable or in post variable but if still you want to send it like this are you able to tell me what are you getting in password variable in login page or are you having any error? – Emraan Khalid Jul 28 '20 at 06:09