-1
if (isset($_POST['submit'])) {
  $email = $_POST['email'];
  $pass = $_POST['password'];

  $query = "select * from register where email = '".$email."'";
  $select = mysqli_query($connect, $query);
  $num = mysqli_num_rows($select);
  if ($row = mysqli_fetch_assoc($select)) {

    $dbpass = $row["password"];
     //if (password_verify($pass, $dbpass)) {
      # code...
      if($num>0) {
      $role = $row["role"];
      if($role == "admin"){
      // if ($num > 0 && $role == "admin") {
        $_SESSION['username'] = $email;
        $_SESSION['role'] = 'admin';
        
        echo "hello student";
      } else if ($num > 0 && $role == "student") {
        $_SESSION['username'] = $email;
        echo "hello student";
      } else {
        $_SESSION['status'] = "Invalid email address or password";
        //header('Location:login.php');
      }
    }

  }
  else {
    $_SESSION['status'] = "Email/password is invalid";
    // header('Location:login.php');
  }
}

THis is the login code i have used blowfish algorithm in it but it didnot doing well i dont know why because it is not giving me errors i think it is confusing in roles because i have and admin role teacher and student i want login according to rules that i have mentioned

I have tried to solve this issue i have followed the syntax from different tutorials as well as from php official documentation but still i am facing the problem of login now i want help from the legend developers THanks

Asad Ali
  • 1
  • 2
  • 3
    **Warning:** You are wide open to [SQL Injections](https://php.net/manual/en/security.database.sql-injection.php) and should use parameterized **prepared statements** instead of manually building your queries. They are provided by [PDO](https://php.net/manual/pdo.prepared-statements.php) or by [MySQLi](https://php.net/manual/mysqli.quickstart.prepared-statements.php). Never trust any kind of input! Even when your queries are executed only by trusted users, [you are still in risk of corrupting your data](http://bobby-tables.com/). [Escaping is not enough!](https://stackoverflow.com/q/32391315) – Dharman Aug 11 '23 at 19:16

0 Answers0