dqp10099 2014-06-16 15:25
浏览 9
已采纳

PHP标头无法正常工作(GoDaddy)[关闭]

I am trying to make a login page but I can't seem to get the header to show up.

session_start();

$_SESSION['prevURL'] = $_SERVER['REQUEST_URI'];

if(!$_SESSION['set'])
{
header("location: main_login.php");
}
  • 写回答

2条回答 默认 最新

  • doulechou0700 2014-06-16 15:53
    关注

    Based on your comment. You cannot show (print, echo) HTML before the Session_start();

    <!DOCTYPE html>
    <html>
    <?php 
    
    session_start(); 
    
    $_SESSION['prevURL']=$_SERVER['REQUEST_URI']; 
    //make this $_SESSION[ 'adminSet'] if it 's an admin-only page
    
    if(!isset($_SESSION['set']))                {                   
    
        header("location: main_login.php");                 }   
    ?> 
    <head>   
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script>    
        <script src="/bootstrap/js/bootstrap.js"> </script>    
        <script src="/bootstrap/js/bootstrap.min.js"> </script>
    

    Should be changed to this:

    <?php 
    session_start(); 
    
    $_SESSION['prevURL']=$_SERVER['REQUEST_URI']; 
    //make this $_SESSION['adminSet'] if it 's an admin-only page
    
    if(!isset($_SESSION['set']))                {                   
    
        header("location: main_login.php");                 }   
    ?> 
    <!DOCTYPE html>
    <html>
    <head>   
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script>    
        <script src="/bootstrap/js/bootstrap.js"> </script>    
        <script src="/bootstrap/js/bootstrap.min.js"> </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?