This question already has answers here:
How to fix “Headers already sent” error in PHP
                                
                                    (11个答案)
                                
                        
                                3年前关闭。
            
                    
<?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>';
        }
    }
}
?>

最佳答案

在到达您的header()指令之前,已经完成了一些输出。您的格式混乱,但是页面的第一个字符之前可能有空格

<?php


但这可能是不好的粘贴。

07-24 09:37
查看更多