<?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>';
}
}
}
?>
Asked
Active
Viewed 84 times
0
3 Answers
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
-
Sorry for poor formatting... In my actual code there are no spaces... – Karthik Mar 02 '16 at 07:55
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
- add
ob_start
just after the<?php
- Place
exit();
ordie()
after your header.

urfusion
- 5,528
- 5
- 50
- 87