This question has already been answered:

<?php session_start (); $db = mysqli_connect('localhost', 'root', ''); mysqli_select_db ($db, 'users'); $select = @mysqli_query($db, "SELECT log,passw FROM test1 "); if (!$select) exit ('#110'); $row = @mysqli_fetch_row ($select); if(!row) exit ('#111'); ?> <!DOCTYPE html> <html> <head> <title></title> </head> <body> <h1>Админ Панель</h1> <div style="background-color: #d3d3d3; width: 200px; padding: 10px"> <form method="post"> login:<br> <input name="log" type="text"><br> password:<br> <input name="passw" type="password"><br><br> <input type="submit" name="button" style="cursor: pointer"><br><br> </form> <?php if($_POST['button']){ $log = $_POST['log']; $passw = $_POST['passw']; if(($log == $row[0]) and ($passw == $row[1])){ $_SESSION['auth'] = $log; echo "Enter to admin -> <a href='admin.php'> admin </a>"; }else{ return exit ('Not correct'); } } ?> </div> </body> </html> 

Marked as a duplicate by participants Alexey Shimansky , Vadim Ovchinnikov , AK , D-side , Grundy Jan 20, 17 at 6:14 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    remove the space before starting <? php - L. Vadim
  • And where is the code for which it scolds? where you actually set this cookie - Naumov
  • I removed them and nothing 2 errors gives out Warning: session_start () [function.session-start]: Cannot send session cookie - headers already sent by (output started by D: \ OpenServer \ OpenServer \ domains \ localhost1 \ admin \ index.php : 1) in D: \ OpenServer \ OpenServer \ domains \ localhost1 \ admin \ index.php on line 2 Warning: session_start () [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D : \ OpenServer \ OpenServer \ domains \ localhost1 \ admin \ index.php: 1) in D: \ OpenServer \ OpenServer \ domains \ localhost1 \ admin \ index.php on line 2 - user234201

2 answers 2

I think the problem is that you have spaces before the start of the script, remove the spaces before <?php

    Solved a problem. Just the encoding was utf-8 without BOM

    • one
      on the contrary .... she was with BOM, but without BOM ........ actually in the link to the duplicate it is written - Alexey Shimansky