0

I am working on a web portal for a school project and I need to create a signature. I have a table called student in my database where I have supervisor_id_dos and supervisor_id_sup2.

Now I want to use session to check who is logged in and direct them to a particular page to sign but the if statement doesn't run, it skips and loads the page under the else statement.

I don't know what am doing right

 <?php   



include "connect.php";  



session_start();    <br/>



$sql = "SELECT * from student WHERE level ='user' and (supervisor_id_dos='$_SESSION[username]'OR      supervisor_id_sup2='$_SESSION[username]')";
$result = mysqli_query($con, $sql);


$row = mysql_num_rows($result);  
if($row){ 
    if($_SESSION["username"] = $row["supervisor_id_dos"])
    { 

    header("Location: dos_sign.php"); 
    } 

else{ 
    header("Location: wrong_sign.php");
}    


}  






?>

code

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119

1 Answers1

2

You have to use == instead of = inside IF statements to compare values, here is more information about PHP Comparison Operators

Try to put exit() after use of header() redirect, it will prevent the rest of php code to get executed

Then, I think you also have an error in your MySQL query where you don't have a space before OR

Seva Kalashnikov
  • 4,262
  • 2
  • 21
  • 36