Hi there,
Basically im making a php website & im making a log-in page.
The login page is fine, and ive made a login verify page and login protected page so that if the credentials provided are correct then it will verify and go onto protected. If not then it should throw up an error stating its invalid. The code I have is as follows;
[php]<?php
$username = “student”;
$password = “student”;
$hostname = “localhost”;
$db = “details”;
//connection to the database
$dbc = mysqli_connect($hostname, $username, $password, $db);
if (mysqli_connect_errno($dbc))
{
echo "Database connection could not be established: " . mysqli_connect_error();
}
//Execute query
if(isset($_POST[‘username’])){
$query = “SELECT password FROM users WHERE username =”".$_POST[‘username’].""";
$result = mysqli_query($dbc , $query) or die(mysqli_error($dbc));
$row = mysqli_fetch_row($result);
if($row[0] == $_POST['password']){
$_SESSION["Authenticated"] = 1;
session_write_close();
header("Location:Login_Protected.php");
} else {
echo "Authencication failed";
}
}
// User is logging out
if (isset($_GET[“logout”])){
session_destroy();
header(“Location:Login.php”);
}
?>[/php]
However the problems I am experiencing are baffling me and i need some help. When I click submit on the login form it just goes straight to the login verify page and sits there and displays nothing. Even if i change the name of the database and make it wrong it does the same. As you can see earlier, it should tell me the connection of the db can not be established but im not even getting that if its wrong. Can anyone help? Ive provided the right and wrong credentials and it dosnt make any difference. Just sits on login verify page.
Any help would be appreciated.