Php Login Authentication Not Working
I have two .php files. All html and php, no SQL and will not be needing/using it. One is the login page, the other is the destination. When I put in the log in details I have set,
Solution 1:
@Sean beat me to it, nice job :-)
If you remove the action="dest.php"
it should work. Right now you are sending the form to a page that does not check the values of the username and password, thus the session variable is not set.
<formmethod="post">
Username: <inputtype="text"name="user"/>
....
</form>
Solution 2:
action="dest.php"
You must make sure code below is in the file dest.php
, and delete it from login.php
.
<?php
session_start();
$username="testu";
$password="testp";
$_SESSION['logged_in']=false;
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
header("Location: dest.php");
exit;
}
if (isset($_POST['user']) && isset($_POST['pass'])) {
if ($_POST['user'] == $username && $_POST['pass'] == $password) {
$_SESSION['logged_in'] = true;
header("Location: dest.php");
exit;
}
}
?>
Post a Comment for "Php Login Authentication Not Working"