The user enters the site. Through ajax there is a request for login.php.

login.php:

<?php if(isset($_POST['login'])); { session_start(); $login = $_POST['login']; $pass = $_POST['pass']; include ('config.php'); $log = mysql_fetch_array(mysql_query("SELECT * FROM `db_users` WHERE username = '$login'")); $login_ms = $log['username']; $pass_ms = $log['password']; $steam_id = $log['steam_id']; $_SESSION['flag'] = $log['flags']; if ($pass == '') { echo "<div class='status-error'>Неправельный логин или пароль.</div> <script>$('.status-error').slideDown('slow'); setTimeout(function() { $('.status-error').slideUp('slow'); }, 3000); </script>"; } else { if ($login_ms == $login and $pass == $pass_ms) { $_SESSION['login'] = $login_ms; $_SESSION['steam_id'] = $steam_id; echo "<div class='status-accept'>Добро пожаловать ".$login_ms.".</div> <script>$('.status-accept').slideDown('slow'); setTimeout(function() { $('.status-accept').slideUp('slow'); }, 3000); setTimeout(function() { window.location.replace('/'); }, 1000); </script>"; } else { echo "<div class='status-error'>Неправельный логин или пароль.</div> <script>$('.status-error').slideDown('slow'); setTimeout(function() { $('.status-error').slideUp('slow'); }, 3000); </script>"; } } } ?> 

Next, in head.php I also run session_start (); :

 <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="<?php echo $adm['sitename'].' - '.$adm['description'] ?>"> <meta name="keywords" content=""> <?php session_start(); $adm = mysql_fetch_array(mysql_query('SELECT * FROM `admin`')); $users = mysql_fetch_array(mysql_query('SELECT SUM(onl) as onl FROM `db_users`')); $global = mysql_fetch_array(mysql_query('SELECT SUM(db_users.kill) as kil,SUM(death) as ded,SUM(animal) as ani FROM `db_users`')); ?> 

Index.php

 <!DOCTYPE html> <html lang="ru"> <?php include ('inc/config.php'); include ('inc/head.php'); ?> <body> 

NotePad ++ UTF-8 WITHOUT BOOM does not help. If I transfer include ('inc / head.php'); higher than <!DOCTYPE html> also does not help.

  • and if echo 'hello'; to remove? ....... head included in login file? - Alexey Shimansky
  • one
    Well, think about it yourself, if your head is enabled in login, what happens? I ’m carrying ......... we ’re reading cannot-modify-header-information.ru penetrate - Alexey Shimansky
  • one
    Now analyze ....... session_start and header should be called before any output . Where do you think the <!DOCTYPE html> <html lang="ru"> information is placed before or after the head ? I hope the hint is clear - Alexey Shimansky
  • one
    The campaign will just have to hide php errors, in such a code it’s hard to look for such a small problem. It's another time to write a site with error mode enabled.) - Sauron
  • one
    Если я перенесу include ('inc/head.php'); выше чем <!DOCTYPE html> тоже не помогает. .............. repeat again ... and re-attach the link cannot-modify-header-information.ru and this phpfaq.ru/newbie/headers ...... session_start and header should be called before any output ....... see ... is there head.php in the head.php file before session_start() ? - Alexey Shimansky

4 answers 4

Try to save the file in encoding: UTF-8 without BOM.

You can do this in the programs Notepad2, Notepad ++, etc.

If it doesn't help, then read it.

    This error indicates that something is displayed on your screen before calling the session_start() function. If there is nothing there, it is possible that your editor has the utf-8 encoding, and there must be utf-8 без BOM since extra characters are added at the beginning of the file.

    • I just checked all the files "utf-8 without BOM" - Sauron
    • Show the code of the file in which the error occurs - alias
    • An error occurs where the session_start is located, that is, if I transfer it to another menu.php, it shows an error on it. - Sauron
    • If I remove it, the hello text is not shown, that is, it does not see the session. - Sauron
    • I read this in your question. Please show the file code so that I can see what you have before session_start() . If you show the file code it will be much easier for me to help you :) - alias

    And you create a new file without a bom and copy the contents of the old one and rename it. well, respectively, the entire chain of connected files should be without a bong and nothing should be displayed before the session starts

      I acted this way. All session_start(); removed. One session_start (); added on config.php Further already did include. Yes, this is the most important to include('config.php'); should always be on top of everything))). Thanks for the help I will know