In the table with users there is a type column in which there are only 2 types of admin and user, the handler code presented below checks if it is an admin then redirect to the admin.php page, if another type is different from the first one to the user.php page. log + pass admin redirect is but if the type user gives an error:

No contact!

Warning: session_start (): Cannot send session cache limiter - headers already sent (D: \ OSPanel \ domains \ regrole \ do_login.php: 24) in D: \ OSPanel \ domains \ regrole \ do_login.php on line 14

Warning: Cannot modify header information - headers already by (output started at D: \ OSPanel \ domains \ regrole \ do_login.php: 24) in D: \ OSPanel \ domains \ regrole \ do_login.php on line 22

include('connect.php'); if(isset($_POST["submit"])){ $email=$_POST["txtemail"]; $pass=$_POST["txtpass"]; $query=mysqli_query($con,"SELECT email,pass,type FROM users"); while($row=mysqli_fetch_array($query)){ $db_email=$row["email"]; $db_pass=$row["pass"]; $db_type=$row["type"]; if($email==$db_email && $pass==$db_pass){ session_start(); $_SESSION["email"]=$db_email; $_SESSION["type"]=$db_type; if($_SESSION["type"]=='admin'){ header("Location:admin.php"); } else header("Location:user.php"); }else echo("Нет контакта!"); } } 
  • one
    No output of anything before complete processing. For this you can use ob_start (), ob_end_flush (), ob_flush () (For documentation in search engines). The rest is the usual redirect using header. And by the way, the header is already sending data. - Adokenai

1 answer 1

The error indicates that the headers have already been sent. See if there is any output ( echo , print , etc.) before session_start() ;

And read the mistakes! What do you have in the do_login.php file on lines 14 and 24?

  • There is nothing like that before session_start (); no, neither in nor in the handler ..14 p. session_start (); 24 p. Echo ("No contact!"); Actually, I cited the do_login.php code as an example; this is all code - Game Bro