本帖最后由 xuzuning 于 2012-05-11 20:38:13 编辑

解决方案 »

  1.   

    没看出 $_SESSION['login'] 在哪里赋值的
      

  2.   


    <?php session_start();?><?php
    include("conn.php");
    $username = trim($_POST['username']);
    $paw = md5(trim($_POST['paw']));
    $post=$_POST['check'];
    $errmsg = '';
    if (!empty($username)) { 
        if (empty($username)) {
            $errmsg = '数据输入不完整';
        }
        if(empty($errmsg)) { 

            
            if (mysqli_connect_errno()) {
                $errmsg = "数据库连接失败!\n";
            }
            else {
               
                $sql = "SELECT * FROM user WHERE username='$username' AND pwd='$paw'";
                $result = mysql_query($sql);
               if ($result && mysql_num_rows($result) > 0 && $post==$_SESSION[check_pic]) {              
                     echo "<script>alert('登陆成功');window.location.href='../admin/index.php'</script>";
                   
               }else {
                    echo "<script>alert('用户名或者密码和验证码不正确');window.location.href='login1.php'</script>";
                }
       
            mysql_free_result($result);
    mysql_close($db);
            }
        }
    }?>登陆代码
      

  3.   

    在数据操作后登陆成功那里加一句:$_SESSION['login'] = $user; 
      

  4.   

    5楼的哥哥 好像不对呀<?php session_start();?><?php
    include("conn.php");
    $username = trim($_POST['username']);
    $paw = md5(trim($_POST['paw']));
    $post=$_POST['check'];
    $errmsg = '';
    if (!empty($username)) {  
      if (empty($username)) {
      $errmsg = '数据输入不完整';
      }
      if(empty($errmsg)) {      
      if (mysqli_connect_errno()) {
      $errmsg = "数据库连接失败!\n";
      }
      else {
        
      $sql = "SELECT * FROM user WHERE username='$username' AND pwd='$paw'";
      $result = mysql_query($sql);
      if ($result && mysql_num_rows($result) > 0 && $post==$_SESSION[check_pic]) {   
      echo "<script>alert('登陆成功');window.location.href='../admin/index.php'</script>";
        $_SESSION['login'] = $user;
    }else {
      echo "<script>alert('用户名或者密码和验证码不正确');window.location.href='login1.php'</script>";
      }
        
      mysql_free_result($result);
    mysql_close($db);
      }
      }
    }
    ?>这样对吗?
    这样写好像不对呀
      

  5.   

     $_SESSION['login'] = $username;。楼主不会PHP吗- -
      

  6.   

    嗯 这个调对了 可是进入index.php这个页面会不停的刷新 怎么回事呀?
      

  7.   

    学习php不是很久 对于你们来说还是一个新手 呵呵
      

  8.   

    <?php
    session_start();
    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php if (empty($_SESSION['login'])) {
        echo "<script>alert('你没有访问权限,请先登录!');window.location.href='../login/login1.php'</script>";
        exit;
    }
    else{
         echo "<script>alert('欢迎光临!');window.location.href='index.php'</script>";
        }
    ?>因为这个欢迎光临之后又重定向到index.php了。。
      

  9.   


    <?php
    session_start();
    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php if (empty($_SESSION['login'])) {
        echo "<script>alert('你没有访问权限,请先登录!');window.location.href='../login/login1.php'</script>";
        exit;
    }
    else{
     echo "<script>alert('欢迎光临!');window.location.href='../admin/index.php'</script>";
    }
    ?>我已经改为这样了 还是不行呀
      

  10.   

    出现欢迎光临之后点击确定就不会动了 不是挑战index.php这个界面上
      

  11.   

    我的意思是去掉成功登陆的windows.location.href楼主,你这样不太好吧太夸张了- -
      

  12.   


    <?php include("../login/qx.php") ;?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    <frameset rows="56,*" cols="*" frameborder="no" border="2" framespacing="2">
      <frame src="top.php" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="top" />
      <frameset rows="*" cols="186,*" framespacing="0" frameborder="no" border="0">
        <frame src="lift.html" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" title="left" />
        <frame src="mian.html" name="mainFrame" id="mainFrame" title="main" />
      </frameset>
    </frameset>
    <noframes><body>
    </body></noframes>
    </html>17楼的前辈 是这样的 不知道为什么 我真的没有办法了
      

  13.   

    你到底有几个index.php  ?
    #20 又是哪个文件。 其实,我已经看晕了。
      

  14.   

    整个网站有两个,一个是admin/index.php一个是index.php总的有两个我不停的刷新的那个是在admin文件夹下面的那个。
      

  15.   

    admin下面的index.php的代码是什么?
      

  16.   

    <?php include("../login/qx.php") ;?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    <frameset rows="56,*" cols="*" frameborder="no" border="2" framespacing="2">
      <frame src="top.php" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="top" />
      <frameset rows="*" cols="186,*" framespacing="0" frameborder="no" border="0">
        <frame src="lift.html" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" title="left" />
        <frame src="mian.html" name="mainFrame" id="mainFrame" title="main" />
      </frameset>
    </frameset>
    <noframes><body>
    </body></noframes>
    </html>
    是这个哥
      

  17.   

    <?php include("../login/qx.php") ;?> 这句代码在作怪吧。跳转到index.php,而index.php里面也有跳转。
      

  18.   

    不是很明白 能写出来给我看看嘛?我该怎么修改 qx.php这个代码我也贴出来了 我真的不知道怎么修改
      

  19.   

    <?php
    session_start();
    ?>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php if (empty($_SESSION['login'])) {
      echo "<script>alert('你没有访问权限,请先登录!');window.location.href='../login/login1.php'</script>";
      exit;
    }
    else{   
    echo "<script>alert('欢迎光临!');window.location.href='../admin/index.php'</script>"; //登陆成功后进入该分支。而你又让它跳转到原页面。所以重复进入该分支。一直在跳转。还不明白?
    //解决办法就是:不要在/admin/index.php包含qx.php。
    }