I’ve made a register and a log in page and they are both connected to the same database. Register page works, but when i enter in Username and Password for log in page I get an error saying “Sorry, your account was not validated”.
Here is my login page:
[php]<?php
session_start();
//include the database connection
include(‘dbc.inc.php’);
//check to see if the connection was successful
if(!$db)
{
echo “
Sorry we cannot process your request at this time. Please try again later.
\n”;
echo “<a href = “index.php”>Home
\n”;
exit;
}
//check for form submission
if($_SERVER[‘REQUEST_METHOD’] == ‘POST’)
{
//minimal form validation
if(isset($_POST['userid'], $_POST['password']))
{
//declare variables
$tablename='users';
$userid = trim($_POST['userid']);
$password = $_POST['password'];
$access = 'U';
//check if userid & password is in the database
$query = "SELECT userid, access, password from $tablename WHERE userid = '$userid' AND password = SHA1('$password')";
//echo "$query";
$result = mysqli_query($db, $query);
$row = mysqli_fetch_row($result);
if(!$row)
{
echo "<h3>Sorry, your account was not validated.</h3><br />\n";
echo "<a href = \"index.php\">Home</a><br />\n";
exit;
}
else
{
//Create a session for the logged in user
$_SESSION['userid'] = $row[0];
//Set a session variable for access
$_SESSION['user_access'] = $row[1];
}
}//end if minimal form validation
}//end if check for form submission
?>[/php]