Im trying a write a login page that would only log a user in if they have activated their account.If they havent activated yet they should be redirected to the activation page. I dont see why my script isnt working, it just displays the "username is required " error message. I think my if statement might be wrong? user.php is the user profile that should be accessed after successful login activation.php is the where they activate their account.
<body>
<?php
if ($_POST['submit']){
$getuser=$_POST['uname'];
$getpass=$_POST['pword'];
if($getuser){
if($getpass){
require("./mysql.php");
$query=mysqli_query($conn,"SELECT * FROM userdet WHERE username='$getuser'&& password='$getpass'");
$numrows = mysqli_num_rows($query);
if($numrows==1){
$row =mysqli_fetch_assoc($query);
$dbactive=$row['status'];
if ($dbactive==1){
$query=mysqli_query($conn,"SELECT * FROM userdet WHERE username='$getuser'&& password='$getpass' && status='1'");
$_SESSION['username']=$getuser;
header("Location:user.php");
}
else
//$errormsg = "Your account has not been activated";
header("Location:Activation.php")
}
else
$errormsg="Username not found";
mysqli_close($conn);
}
else
$errormsg="Password is required";
}
else
$errormsg="Username is required";
}
else
$errormsg="";
echo "<form action='./login.php' method='post' >
<table>
<tr>
<td> </td>
<td> $errormsg</td>
</tr>
<tr>
<td> Username:* </td>
<td> <input type='text' id='uname' name='username' value='$getuser' /></td>
</tr>
<tr>
<td> Password:* </td>
<td><input type='password' name='pword' id='code' value='$getpass' /></td>
<tr>
<td></td>
<td><input type='submit' name='submit' value='Log in' /></td>
</tr>
</tr>
</table>
</form>";
?>
</body>