dongyun9120 2018-03-01 10:10
浏览 49

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

This question already has an answer here:

After entering username and password, showing this eror

Warning: Cannot modify header information - headers already sent by (output started at /storage/****************/public_html/Include/Header.php:1) in /****************/public_html/user_login.php on line 17

in localserver it works fine but after uploading to 000webhost it gives the above error

please help me, thanks

<?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")
?>
</div>
  • 写回答

4条回答 默认 最新

  • dongsu1951 2018-03-01 10:24
    关注

    After the includes, remove the two following lines :

    ?>
       <?php
    

    Because, between close tag and open tag, there is multiple spaces sent to the output, which causes this warning.

    Finally, add exit() after header() to stop the script.

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类