-1

I found this code on stackoverflow. I'm using this but I need to know how I can go in another page (e.g. hello.html) from the echo instead of " echo "Hello, ".$local_user."!"; ". Thanks for help!

PHP

   
<?PHP
$local_user = "user"; 
$local_password = "123"; 
if (isset($_POST['login'])) // check if user enter submit
{
    $u_post = $_POST['username']; // get user input 
    $p_post = $_POST['password']; // get password input 


    if ($local_user == $u_post) 
    {
        if ($local_password == $p_post) 
        {
            
            
            echo "Hello, ".$local_user."!"; 
            die(); //you can arrive the user to welcome page from here 
            
        }
        echo "Password is not correct !"; // if username is correct but password is not
        die(); 
    }
    else 
    {
        echo "Username is not correct !";  // if username is not correct then no need to check password ! .
        die(); 
    }
}
?>

HTML

<html>

<head>

    <title>Login</title>
    
</head>

<body>


    <div id="form_login">
        <form action="" method="POST">
            <input type="text" style="border:1px solid #e6e6e6; text-align:center; color: #b3b3b3;" name="username" placeholder="Enter username" />
            </br></br>

            <input type="password" style="border:1px solid #e6e6e6; text-align:center; color: #b3b3b3;" name="password" placeholder="Enter password" />
            </br></br>
            <input type="submit" id="button" value="Login" name="login" />
        </form>
    </div>



</body>

</html>

All works fine, only need this little thing to make me happy! :)

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
I'm Not A Robot
  • 296
  • 3
  • 12

1 Answers1

1

You can use header() to redirect your user to another page:

header('Location: /hello.html');
exit;

See: header()

fdehanne
  • 1,658
  • 1
  • 16
  • 32