$email_acc = file_get_contents("../../acc/$id/info/email.dat"); $pass_acc = file_get_contents("../../acc/$id/info/pass.dat"); $nickname_acc = file_get_contents("../../acc/$id/info/nickname.dat"); 

../../acc/$id/info/ - this is the path with the data from the account
if the password and login do not match, everything is fine - it writes the "wrong password", but if I enter it correctly, it writes

 Warning: Cannot modify header information - headers already sent by (output started at "путь":49) in "путь" on line 83 Warning: Cannot modify header information - headers already sent by (output started at "путь":49) in "путь" on line 84 Warning: Cannot modify header information - headers already sent by (output started at "путь":49) in "путь" on line 85<br> на этих линиях код такой: <br> setcookie("id","$id", time() + 99999999, "/");<br> setcookie("nickname","$nickname_acc", time() + 99999999, "/");<br> header( 'Location: ../../', true, 307 ); <form action='index.php' method='post'> <input type='email' name='email'> <input type='password' name='pass'> <input type='submit'> </form> 

  if($_POST) { $count_id = file_get_contents('../register/count_id.dat'); for($i=1; $i<$count_id; $i++) { $id = "id".$i; $email_acc = file_get_contents("../../acc/$id/info/email.dat"); $pass_acc = file_get_contents("../../acc/$id/info/pass.dat"); $nickname_acc = file_get_contents("../../acc/$id/info/nickname.dat"); if($pass == $pass_acc and $email == $email_acc) { setcookie("id","$id", time() + 99999999, "/"); setcookie("nickname","$nickname_acc", time() + 99999999, "/"); header( 'Location: ../../', true, 307 ); break; echo "ok"; } else { echo ' <h4>Неправильний логін або пароль!</h4> '; } } } ?>[![весь код простите что украинский делаю укр сайт][1]][1] 

    1 answer 1

    http-response headers cannot be sent after you have started outputting response body data. if your form code is displayed before the headers are issued, then nothing happens, you need to separate the data output and the condition check ie if you are successfully logged in, set $success=1; and later check if ($success) does not print the form.

    for the rest, the code is of course terrible, but if you are just learning, then ok.

     весь код простите что украинский делаю укр сайт 

    so we see that this is a code in a foreign language, why are you apologizing?

    • This is a question of the site there should have been a photo but not bug out the attention - BedOmar
    • and where you need to put $ success = 1; when the page is updated, the variable will default to zero - BedOmar
    • when updating you, I understand, already in the cookie look, if set, then $ success = 1, otherwise 0; - strangeqargo
    • do you understand my cookies do not fall asleep as you see - BedOmar
    • doesn’t complain because the output happens before the cookies are posted, transfer it below - strangeqargo