I want to restrict registered user from login in with not just username and password, it should:
- if the user
voting_status='a', allow the user to login with their username and password - if the
voting_status='b'it should restrict the user from login in and echo"you're not allowed to login"else username/password incorrect.
But I don't know how to go about it, because I'm a novice in coding. I really need assistance. This is what I've been able to do so far.
<?php
define('DB_HOST', 'localhost');
define('DB_NAME', 'university portal');
define('DB_USER','root');
define('DB_PASSWORD','password007');
$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
/*
$ID = $_POST['user'];
$Password = $_POST['pass'];
*/
function SignIn()
{
session_start(); //starting the session for user profile page
if(!empty($_POST['UserName'])) //checking the 'user' name which is from Sign-In.html, is it empty or have some text
{
$query = mysql_query("SELECT Username, Password, voting_staus
FROM voters
where Username = '$_POST[UserName]',
Password = '$_POST[password]'
voting_status = 'a' ")
or die(mysql_error());
$row = mysql_fetch_array($query) or die(mysql_error());
if(!empty($row['Username']) AND !empty($row['Password'])){
if($row['voting_status']){
$_SESSION['Username'] = $row['Password'];
echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE...";
}
}
elseif($row[voting_status]=='b') {
echo "You are not allow to Login Here";
} else {
echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY...";
}
}
}
if(isset($_POST['submit'])) {
SignIn();
}
?>