Age old question. I have tried everything I can think of included multiple searches on this site.
My example URL is mydomain.com/login.php?aircraft_id=3542
$aircraft_id = $_GET['aircraft_id'];
echo $aircraft_id; //This works fine to verify the $_GET is working
... bunch of login code to verify user ... if password verified:
session_start()
$_SESSION['username'] = $username;
header('Location: test.php?aircraft_id=' . $aircraft_id);
I can not get this variable to pass to the next page for the life of me.
I have tried
header('Location: test.php?aircraft_id=' . $aircraft_id);
header("Location: test.php?aircraft_id=$aircraft_id");
as well as other forms of single quote / double quotes.
The $_GET is working as I can echo the $aircraft_id on the login page but once I submit, the header will not capture the variable to pass on to the next page.
Here is the form code:
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group <?php echo (!empty($username_err)) ? 'has-error' : ''; ?>">
<label>Username</label>
<input type="text" name="username"class="form-control" value="<?php echo $username; ?>">
<span class="help-block"><?php echo $username_err; ?></span>
</div>
<div class="form-group <?php echo (!empty($password_err)) ? 'has-error' : ''; ?>">
<label>Password</label>
<input type="password" name="password" class="form-control">
<span class="help-block"><?php echo $password_err; ?></span>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Login">
</div>
<p>Don't have an account? <a href="register.php">Sign up now</a>.</p>
</form>
test.php?aircraft_id=? If so, your variable declaration is wrong, it's probably$_POST[]$aircraft_idlook like?