将登录页面上传到在线服务器后,登录页面无效

时间:2018-03-01 10:10:59

标签: php login-page

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

  

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

在localserver中它工作正常,但上传到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")
?>

4 个答案:

答案 0 :(得分:2)

包含后,删除以下两行:

bullet

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

最后,在?> <?php 之后添加exit()以停止脚本。

答案 1 :(得分:1)

你必须在任何输出之前使用会话(即使'空白输出或html')

答案 2 :(得分:0)

在输出一些代码后,您正尝试修改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');

  ?>

答案 3 :(得分:0)

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

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

查看here了解更多详情