I am having a problem with header redirect on my login page. All was well until I upgraded from php 5.6 to 7.1 yesterday.
The user can enter credentials on a login form, and based on the creds, the user is validated against the database and the login also looks for a cookie on the user’s browser. All I said, all was well until yesterday, the upgrade, and my attempts to migrate to mysql that works (my bad for being years behind the curve).
Anyway, several files (config, variables, error codes, and a login cookie check) are called by include statements prior to any actual php being executed. As I said, i am years behind and am strictly procedural.
Through trial and error, I can get the page to redirect as long as I put a redirect before an included file called login.cookie.check.php. As soon as I put the redirect after that file, redirects fail. I have no clue what in that file is outputting html, but it is. I’ve also tried ob_start to no avail.
Here’s the code from that file:
<?
$remembered = "0";
if (isset($_COOKIE['userkey'])) { // check for a 'key'
$userkey = $_COOKIE['userkey'];
if ($get_username = mysqli_query($link, "SELECT username FROM userkeys WHERE userkey='$userkey' LIMIT 1")) { // there is a cookie, lookup username
while ($row = mysqli_fetch_assoc($get_username)) {
$username = $row["username"];
$remembered = "1";
}
$get_userinfo = mysqli_query($link, "SELECT * FROM users WHERE u_employee_number='$username' LIMIT 1"); // check if the user info validates the db
while ($row=mysqli_fetch_assoc($get_userinfo)) {
$u_name = $row["u_name"];
$u_email = $row["u_email"];
$u_text = $row["u_text"];
$u_employee_number = $row["u_employee_number"];
$u_jpass = $row["u_jpass"];
}
}
}
?>
Any ideas?
Thanks in advance.