Avatar of Natchiket
Natchiket
Flag for United Kingdom of Great Britain and Northern Ireland asked on

trying to navigate to a page

hi everyone
In my index.php file I have a form used for logging in which has login.php as the action

in login.php I have

<?php


require_once 'cls_user.php';

if (isset($_POST['uid']) && isset($_POST['pwd']))
{
    $user = new user;
    $user->let_uid($_POST['uid']);
    $user->let_pwd($_POST['pwd']);
    if ($user->authenticate())
    {
        //echo "authenticated!";
        header('index.php');
    }
}



?>

Open in new window


when the user class authenticates the login it starts a session variable, the idea being when   returning control back to index.php it sees the session variable has been set and acknowledges the user.

the problem is that the 'header' command isn't doing anything, I thought it would go back to index.php but instead I just get a blank screen (or just 'authenticated!' if I uncomment it)

how can I make it go back to index.php or what approach do I need to make it work
PHP

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
WebF00L

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

This article shows the design pattern used for PHP client authentication.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_2391-PHP-login-logout-and-easy-access-control.html

Consider adding error_reporting(E_ALL); to your scripts.  It will save you a lot of trouble because you will be able to see many things that PHP might be hiding from you in its default condition of Notice suppression.
Your help has saved me hundreds of hours of internet surfing.
fblack61