0
<?php

include 'conn/condb.php';
if (isset($_POST['submit'])) {
    if (isset($_POST['username'])and isset($_POST['password'])) {
        $username = $_POST['username'];
        $password = $_POST['password'];
        $query = mysql_query("SELECT username,password FROM login WHERE`username='$username'AND password='$password'");
        if (!$query)
            die("Database access failed: " . mysql_error());
        $rows = mysql_num_rows($query);
        if (($username == 'admin') && ($password == 'keystech')) {
            $_SESSION['username'] = $username;
            $_SESSION['sid'] = session_id();
            header("location:index1.php");
        } else {

            echo "<script type='text/javascript'>alert('Please Enter Your Correct user name And Password..')</script>";

            echo '<script type="text/javascript">window.location="index.html";
   </script>';
        }
    }
}
?>
urfusion
  • 5,528
  • 5
  • 50
  • 87

3 Answers3

0

At some point, before reaching your header() instruction, some output has been made. Your formatting is messed up, but there may be a space at the first character of the page before

<?php

but that could just be bad pasting.

markdwhite
  • 2,360
  • 19
  • 24
0

after your <?php starting just type this ob_start(); it will buffer empty spaces or any output before redirect.

Qazi
  • 5,015
  • 8
  • 42
  • 62
  • Sorry for poor formatting.. And thanks for the replies. I have tried adding ob_start(); and die(); .. But still am facing the same error.. – Karthik Mar 02 '16 at 07:54
  • 1st check that, are coming to proper section, means are you reaching to `header()` section or not, do some step wise testing – Qazi Mar 02 '16 at 09:20
0

Do few things

  1. add ob_start just after the <?php
  2. Place exit(); or die() after your header.
urfusion
  • 5,528
  • 5
  • 50
  • 87