登录页面上传到在线服务器后不起作用



输入用户名和密码后,显示此错误

警告:无法修改标头信息 - 标头已由 发送 (输出开始于 /storage/****/public_html/Include/Header.php:1( in /********/public_html/user_login.php 在第 17 行

在本地服务器中,它工作正常,但在上传到 000webhost 后,它给出了上述错误

请帮助我,谢谢

<?php 
session_start();
include("/storage/****************/public_html/Include/Header.php"); 
include('/storage/****************/public_html/Include/Navbar.php');
include('/storage/****************/public_html/Include/db.php');

    ?>
       <?php
   if(isset($_POST['submit'])){
       $u_username=$_POST['u_username'];
       $u_password=$_POST['u_password'];
       $sql=mysqli_query($link, "SELECT * FROM tbl_user where u_username='$u_username' and u_password='$u_password'");
       $result=mysqli_fetch_array($sql);
       if($result['u_username']== $u_username and $result['u_password']== $u_password){
           $_SESSION['user']=$u_username;
             header("location:/storage/****************/public_html/123.php");

       }else{
           $error= "<div class='alert alert-danger'>ID or Password Incorrect</div>";
       }
   }
  ?>
   <div class="row">
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-left" id="nav">
                <li><a href="index.php"><i class="fa fa-home"></i> Home</a></li>
            </ul></div>

    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
   <!--Main Body-->
     <div class="container">
         <div class="panel panel-primary col-md-9">
            <div class="panel-heading">
                <h3>Admin Login</h3>
            </div>
            <div class="panel-body col-md-7">
              <form class="form-horizontal" action="" method="post">
             <div class="form-group">
                 <label for="Name" class="col-md-5">Your username: *</label>
                 <div class="col-md-7">
                     <input type="text" required name="u_username" class="form-control" placeholder="Your ID Here...">
                 </div>
             </div>
            <div class="form-group">
                 <label for="Name" class="col-md-5">Your Password: *</label>
                 <div class="col-md-7">
                     <input type="Password" name="u_password" class="form-control" placeholder="Your Password Here..." required>
                 </div>
             </div>
             <div class="form-group">
                 <label for="Name" class="col-md-5"></label>
                 <div class="col-md-7 ">
                     <?php if(isset($error)){
                            echo $error; }?>
                 </div>
             </div>
             <div class="form-group">
                 <label for="Name" class="col-md-5"></label>
                 <div class="col-md-7">
                     <input type="submit" name="submit" value="Login" class="btn btn-success btn-block">
                 </div>
             </div>
            <div>
                <h3>Note:</h3> 
                <p>If NOT Registered! Please <a href="contact.php">Contact Us</a>.</p>
            </div>

                </form>

         </div>
     </div>
</div><br>
   <!--End of Main Body-->
   <?php 
include("/storage/****************/public_html/Include/Footer.php")
?>

在包含之后,删除以下两行:

?>
   <?php

因为,在关闭标记和打开标记之间,有多个空格发送到输出,这会导致此警告。

最后,在header()后添加exit()以停止脚本。

你必须在任何

输出之前使用session(即使"空白输出或html"(

在 Header.php 文件中使用 ob_start((。

此函数打开输出缓冲,因此不会从脚本发送输出。 输出存储在内部缓冲区中。

查看此处了解更多详情

您正在尝试在输出一些代码后修改 HTTP 标头。

您可能希望移动这些包含

include("/storage/****************/public_html/Include/Header.php"); 
include('/storage/****************/public_html/Include/Navbar.php');

在对用户进行身份验证后。

它看起来像:

<?php 
session_start();
include('/storage/****************/public_html/Include/db.php');
if(isset($_POST['submit'])){
       $u_username=$_POST['u_username'];
       $u_password=$_POST['u_password'];
       $sql=mysqli_query($link, "SELECT * FROM tbl_user where u_username='$u_username' and u_password='$u_password'");
       $result=mysqli_fetch_array($sql);
       if($result['u_username']== $u_username and $result['u_password']== $u_password){
           $_SESSION['user']=$u_username;
         header("location:/storage/****************/public_html/123.php");
       }else{
           $error= "<div class='alert alert-danger'>ID or Password Incorrect</div>";
       }
   }
include("/storage/****************/public_html/Include/Header.php"); 
include('/storage/****************/public_html/Include/Navbar.php');
  ?>

相关内容

  • 没有找到相关文章

最新更新