你先调用的哪个文件,就在哪个文件开头写上:
<?
session_start();
session_register("username","userpass");
?>

解决方案 »

  1.   

    Mistruster(弱智d):也是一样的啊,$username同样没有什么东西
      

  2.   

    <?
     session_start();
     session_register($username);
     require("../conn.php");
     //登陆开始
              $sql="select username,userpass from phpbbsuser where username='$user' and userpass='$pass'" ;
              $result=mysql_query($sql,$conn);
              $row=mysql_fetch_array($result);
              if (strlen($row["username"])==0){
              ?>
     <script>
     alert("登录信息有错误,请重新登录!")
     location.href="index.php"
     </script>
              <?
     }
     else{
             $username=$user;
             echo session_is_registered($username);
             echo $username;
              ?>
       <script>
       location.href="../index.php"
      </script>
              <?
               }
                mysql_close($conn) or die ("不能关闭数据库,正忙");
                 exit();
     ?>
      

  3.   

    c:\tmp\sess_f1a3485e92f7b966c5f1e63d1fe290c5
    是 0字节还是有内容?
      

  4.   

    你把所有 $user 换成 $username
    然后直接 echo $username; 就行了
    还有 session_is_registered($username); 是什么意思?
      

  5.   

    session_is_registered($username); 意思是指这个$username是否已经注册为session变量了
      

  6.   

    那么session_is_registered 部分是怎么显示的?是1吗?
    你既然注册的是 $username 为什么还用 $user呢?
      

  7.   

              <?
    }
    else{   session_start();           (你把"session_start();"换在这里看看)
            $username=$user;
              session_register($username);
              echo session_is_registered($username); //显示为1 证明已经注册
              echo $username;                        //有显示,lgphp
              ?>
      

  8.   

    to rosen(考试机器)
    如果按你的做法,就等于说运行到这里才注册 $username ,那么$username的值就应该是空
    -------------------------------------------------------------------------------
    使用session,我的理解是:每个文件开头session_start();
                            最初的那个文件 session_register(...);
                            每个文件就都可以使用了。
                            最后在来个<a href="goto.php?to=http://..." target=_top>退出</a>
                   -- goto.php --
    <?
    session_start();
    session_destroy();
    header("Location: $to ");
    ?>
      

  9.   

    "select username,userpass from phpbbsuser where username='$user' and userpass='$pass'"
    上面这句有问题为什么不像下面这样呢?
    $sql = "select userpass from phpbbsuser where username= $user";
    $result=mysql_query($sql,$conn);
    $row=mysql_fetch_array($result);
    if ( $row["userpass"] == $pass ) {
    ...........
    } else {
    ...........
    }
      

  10.   

    遇到过同样的问题,只是我那时用的是cookie,
    查资料可知,cookie or sesseion 存入客户端中时,
    同时记录变量隶属的路径,这意味着在目录A下存的变量
    在目录B中的php文件中是得不到的,
    那么该怎么办呢?当然这个就无需多言了
      

  11.   

    既然注册了全局变量 $username ,$userpass 就要使用它们。
    其它变量(如:$user,$pass) 在文件间是不传值的
    你的代码中:
            $username=$user;     //你把一个空值传给了$username
            echo session_is_registered($username);
            echo $username;也许是我错了,但我觉得最好不要使用未注册的变量。
      

  12.   

    问题就出在这:$username=$user;
              session_register($username);
              你应该把两句换个位置:
    session_register($username);
    $username = $user;
      

  13.   

    <?
     session_start(); require("../conn.php");
     //登陆开始   $sql="select username,userpass from phpbbsuser where username='$user' and userpass='$pass'" ;
              $result=mysql_query($sql,$conn);
              $row=mysql_fetch_array($result);
              if (strlen($row["username"])==0){
              ?>
     <script>
     alert("登录信息有错误,请重新登录!")
     location.href="index.php"
     </script>
              <?
     }
     else{
             session_register($login);
             $login=$row["username"];
             echo session_is_registered($login);
             echo $login;
              ?>
            <script>
       location.href="../index.php"
           </script>
              <?
               }
                mysql_close($conn) or die ("不能关闭数据库,正忙");
                 exit();
     ?>换了位置也不行呀
      

  14.   

    $user 和 $pass 是form表单传过来的值
      

  15.   

    index.php
    <?
       include("conn.php");
      //获得论坛名列表
      $sql="select * from phpbbsborard";
      $result=mysql_query($sql,$conn);
      //取得会员总数
      $sql="select count(*) as userc  from phpbbsuser ";
      $rs=mysql_query($sql,$conn);
      $userc=mysql_fetch_array($rs);
      //取得最新会员
      $sql="select username from phpbbsuser order by addtime desc";
      $rs=mysql_query($sql,$conn);
      $newm=mysql_fetch_array($rs);
      //取得主题数量
      $sql="select count(*) as topic from phpbbsmain where orderid=1";
      $rs=mysql_query($sql,$conn);
      $topic=mysql_fetch_array($rs);
      //帖子总数
      $sql="select count(*) as topicc from phpbbsmain ";
      $rs=mysql_query($sql,$conn);
      $topicc=mysql_fetch_array($rs);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>怀化在线</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
    href="index.files/forum.css" type=text/css rel=stylesheet><style>#Layer0      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 10 }
    #Layer1      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 20 }
    #Layer2      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 30 }
    #Layer3      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 40 }
    #Layer4      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 50 }
    #Layer5      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 60 }
    #Layer6      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 70 }
    #Layer7      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 80 }
    #Layer8      { height: 60px; left: -100px; position: absolute; top: -100px; width: 60px;
                   z-index: 90 }
    </style><script language="JavaScript" src="js/piao.js"></script>
    <STYLE type=text/css>TABLE {
            FONT-SIZE: 12px
    }
    A.daohang:link {
            COLOR: #000000; TEXT-DECORATION: none
    }
    A.daohang:hover {
            COLOR: #cc0000; TEXT-DECORATION: none
    }
    A.daohang:visited {
            COLOR: #333333; TEXT-DECORATION: none
    }
    </STYLE>
    <META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD><BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=0 onload=doplay()>
    <div id="Layer0">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <div id="Layer1">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <div id="Layer2">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <div id="Layer3">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <div id="Layer4">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <div id="Layer5">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <div id="Layer6">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <div id="Layer7">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <div id="Layer8">
      <dd><img src="images/snow.gif" width="25" height="25"></dd>
    </div>
    <table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000">
      <tr>
        <td  height=3 bgcolor="#B84F1D"> <font color="#FFFFFF">&gt;&gt; 欢迎您, <?=$login?> <?if (isset($login)&&$login!="") {?>
           <?=$login?>
              <?
               }
              else{?>
               客人
              <?}?>: </font><a href="reguser/index.php"><font color="#FFFFFF">登陆</font></a><font color="#FFFFFF">
          | </font><a href="reguser/reguser.html"><font color="#FFFFFF">注册</font></a><font color="#FFFFFF">
          | </font><a href="forgotpass.php"><font color="#FFFFFF">忘记密码</font></a><font color="#FFFFFF">
          | </font><a href="online.php"><font color="#FFFFFF">在线</font></a><font color="#FFFFFF">
          | </font><a href="search.php"><font color="#FFFFFF">搜索</font></a><font color="#FFFFFF">
          | </font><a href="help.html"><font color="#FFFFFF">帮助</font></a><font color="#FFFFFF">
          </font> </td>
      </tr>
    </table>
    <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
      <TBODY>
      <TR>
        <TD colSpan=2 height=2><img src="images/in_02.gif" width="662" height="64"></TD>
      </TR>
      <TR>
        <TD bgColor=#cccccc colSpan=2 height=2></TD>
      </TR>
      </TBODY>
    </TABLE>
    <DIV align=center>
    <CENTER>
        <table cellspacing=1 cellpadding=3 width="100%" bgcolor=#efefef
            border=0>
          <tbody>
          <tr bgcolor="#B84F1D">
            <td height="24" width="40%" valign="top" bgcolor="#B84F1D"><font color="#FFFFFF"><img src="images/statistic.gif" width="13" height="15">注册会员数:
              <?=$userc["userc"]?><br>
              主题总数: <?=$topic["topic"]?> | 帖子总数: <?=$topicc["topicc"]?> <br>
              <img src="images/pmon.gif" width="18" height="18">欢迎我们的新成员: <?=$newm[0]?>
              </font><font color="#FFFFFF"></font></td>
            <td height="11" width="60%">
              <div align="center"><img src="images/j2ee.gif" width="468" height="60"></div>
            </td>
          </tr>
          </tbody>
        </table>
        <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
      <TBODY>
      <TR>
            <TD align=middle height=51><FONT
    color=red><B></B></FONT>
              <table cellspacing=1 cellpadding=2 width="100%" border=0>
                <tbody>
                <tr bgcolor="#f3f3f3">
                  <td  colspan=12><font color="#000000">目前论坛总共有 4 人在线。其中注册用户 1 人,访客
                    3 人。 论坛总共被访问 11831 次,共被点击 84178 次。<br>
                     在线名单图例: <img src="images/messages0.gif" width="16" height="11">
                    论坛管理员,  <img src="images/messages1.gif" width="16" height="11">
                     论坛版主,   <img src="images/messages4.gif" width="16" height="11">普通会员,
                     <img src="images/messages2.gif" width="16" height="11">客人或隐身会员<br>
                    </font> </td>
                </tr>
                <tr bgcolor="#f3f3f3">
                  <td class=font105 colspan=12>&nbsp;</td>
                </tr>
                <tr bgcolor=#B84F1D height=21>
                  <td width="6%" align="middle"><font color="#FFFFFF">状态</font></td>
                  <td width="32%" align="middle" bgcolor="#B84F1D"><font color="#FFFFFF">版
                    名</font></td>
                  <td width="12%" align="middle"><font color="#FFFFFF">帖子数量</font></td>
                  <td width="9%" align="middle"><font color="#FFFFFF">主题数量</font></td>
                  <td width="16%" align="middle"><font color="#FFFFFF">斑竹</font></td>
                  <td width="25%" bgcolor="#B84F1D" align="middle"><font color="#FFFFFF">最后发表</font></td>
                </tr>
                <?while ($row=mysql_fetch_array($result)){ ?>
                <tr onMouseOver="this.style.backgroundColor='#E0E0E0';"
      onMouseOut="this.style.backgroundColor='';" bgcolor=#efefef>
                  <td title="" width="6%" height="40">
                    <div align="center"><b><img src="images/lock_b.gif" width="13" height="16"></b></div>
                  </td>
                  <td title="" width="32%" height="40" align="left" valign="top">
                    <div align="left"><b> <a href="list.php?boardid=<?=$row["id"]?>">
                      <?=$row["name"]?>
                      </a> </b><br>
                    </div>
                    <?=$row["content"]?>
                  </td>
                  <td align=left width="12%" height="40"> 23</td>
                  <td align=left width="9%" height="40">32</td>
                  <td align=left width="16%" height="40" >lgphp,<a href="user/member.php?username=lgphp">晚风</a><img src="images/team.gif" width="20" height="20"></td>
                  <td align=left width="25%" height="40">01-23-2002 11:08 AM<br>
                    by lgphp <br>
                    [試用] 欢迎光临Ja.. <img src="images/lastpost.gif" width="14" height="14"></td>
                </tr>
                <?}?>
                </tbody>
              </table>
            </TD></TR></TBODY></TABLE>
        <TABLE cellSpacing=1 cellPadding=2 width="100%" border=0>
          <TBODY>
          <TR bgcolor="#efefef">
            <TD colSpan=8>
              <div align="center"><img src="images/foldernew.gif" width="13" height="16">
                有新帖子的论坛    <img src="images/folderallmeiyou.gif" width="13" height="16">无新帖的论坛  <img src="images/lock_b.gif" width="13" height="16">已经锁定的论坛</div>
            </TD>
          </TR>
          <TR bgcolor="#f3f3f3">
            <TD class=font105 colSpan=8><b>当前热门话题</b></TD>
          </TR>
          <TR align=middle bgColor=#B84F1D height=21>
            <TD align=middle width=30><font color="#FFFFFF">排名</font></TD>
            <TD align=middle><font color="#FFFFFF">主题</font></TD>
            <TD align=middle width=80><font color="#FFFFFF">作者</font></TD>
            <TD align=middle width=80><font color="#FFFFFF">版名</font></TD>
            <TD title=24小时内的人气 align=middle width=70><font color="#FFFFFF">今日人气</font></TD>
            <TD align=middle width=120><font color="#FFFFFF">发帖时间</font></TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>1</TD>
            <TD align=left><A title=主题:色情服务一应俱全的湖南省电力系统的工作总结会议
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=401&amp;articleid=73985&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon20021614285548801082.gif"
          width=15 align=absMiddle border=0>色情服务一应俱全的湖南省电力系统的工...</A></TD>
            <TD title="查看''哑巴''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=lijj&amp;sSessionKey=',350,320)">哑巴</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=401">性爱时空</A></TD>
            <TD>100</TD>
            <TD>2002-1-24 18:45:35</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>2</TD>
            <TD align=left><A title=主题:我眼里的IT生活(演变篇)
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=341&amp;articleid=75622&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon2713587.gif" width=15
          align=absMiddle border=0>我眼里的IT生活(演变篇)</A></TD>
            <TD title="查看''蛋塔''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=hill&amp;sSessionKey=',350,320)">蛋塔</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=341">斑竹专区</A></TD>
            <TD>85</TD>
            <TD>2002-2-3 2:10:22</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>3</TD>
            <TD align=left><A title=主题:我抗议
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=414&amp;articleid=75561&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon2002161200131949669.gif"
          width=15 align=absMiddle border=0>我抗议</A></TD>
            <TD title="查看''吉祥天''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=jixiangtian&amp;sSessionKey=',350,320)">吉祥天</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=414">红杏出墙</A></TD>
            <TD>46</TD>
            <TD>2002-2-2 14:56:21</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>4</TD>
            <TD align=left><A title=主题:大家还是平和一些好,在网络上相识已经不易,何必呢?
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=414&amp;articleid=75819&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon20017282124027766703.gif"
          width=15 align=absMiddle border=0>大家还是平和一些好,在网络上相识已经...</A><IMG height=11
          src="index.files/new.gif" width=28 border=0></TD>
            <TD title="查看''豆子哥''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=hute&amp;sSessionKey=',350,320)">豆子哥</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=414">红杏出墙</A></TD>
            <TD>36</TD>
            <TD>2002-2-4 13:53:24</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>5</TD>
            <TD align=left><A title=主题:恋爱中的男人Vs恋爱中的女人
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=414&amp;articleid=75197&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon200211611061342009527.gif"
          width=15 align=absMiddle border=0>恋爱中的男人Vs恋爱中的女人</A></TD>
            <TD title="查看''snoopy''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=snoopy&amp;sSessionKey=',350,320)">snoopy</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=414">红杏出墙</A></TD>
            <TD>35</TD>
            <TD>2002-1-31 14:46:38</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>6</TD>
            <TD align=left><A title=主题:女生和她的烟
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=402&amp;articleid=75767&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon20021611592128434223.gif"
          width=15 align=absMiddle border=0>女生和她的烟</A><IMG height=11
          src="index.files/new.gif" width=28 border=0></TD>
            <TD title="查看''苏菲亚''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=yiyi710&amp;sSessionKey=',350,320)">苏菲亚</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=402">网恋故事</A></TD>
            <TD>35</TD>
            <TD>2002-2-4 7:11:39</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>7</TD>
            <TD align=left><A title=主题:《雨》(一)
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=414&amp;articleid=75502&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon200172821273320459118.gif"
          width=15 align=absMiddle border=0>《雨》(一)</A></TD>
            <TD title="查看''洁洁陀''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=kili&amp;sSessionKey=',350,320)">洁洁陀</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=414">红杏出墙</A></TD>
            <TD>29</TD>
            <TD>2002-2-1 20:58:43</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>8</TD>
            <TD align=left><A title=主题:女孩子们,你们喜欢什么???????
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=414&amp;articleid=75750&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon200172821273320459118.gif"
          width=15 align=absMiddle border=0>女孩子们,你们喜欢什么???????</A><IMG height=11
          src="index.files/new.gif" width=28 border=0></TD>
            <TD title="查看''善待自己''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=lkmstpl&amp;sSessionKey=',350,320)">善待自己</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=414">红杏出墙</A></TD>
            <TD>25</TD>
            <TD>2002-2-3 20:35:50</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>9</TD>
            <TD align=left><A title=主题:质问“新湖南人”?----兼问红网
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=423&amp;articleid=74612&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon200172821244043881463.gif"
          width=15 align=absMiddle border=0>质问“新湖南人”?----兼问红网</A></TD>
            <TD title="查看''歪把子飞刀''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=zjt666&amp;sSessionKey=',350,320)">歪把子飞刀</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=423">红辣椒论坛</A></TD>
            <TD>25</TD>
            <TD>2002-1-28 13:49:34</TD>
          </TR>
          <TR onmouseover="this.style.backgroundColor='#E0E0E0';"
      onmouseout="this.style.backgroundColor='';" align=middle bgColor=#efefef>
            <TD>10</TD>
            <TD align=left><A title="主题:决不放弃,做美好的女人 (转贴)"
          href="http://community.rednet.com.cn/Forum/Article.asp?OpMod=read&amp;boardid=414&amp;articleid=75469&amp;sSessionKey="><IMG
          height=15 hspace=2 src="index.files/FaceIcon20021612090780383325.gif"
          width=15 align=absMiddle border=0>决不放弃,做美好的女人 (转贴)</A></TD>
            <TD title="查看''纯真''的信息" align=left>&nbsp;<A
          href="javascript:winopen('/Community/ViewUserInfo.asp?AuthorUserName=liki&amp;sSessionKey=',350,320)">纯真</A></TD>
            <TD><A
          href="http://community.rednet.com.cn/Forum/ArticleList.asp?BoardID=414">红杏出墙</A></TD>
            <TD>18</TD>
            <TD>2002-2-1 16:45:30</TD>
          </TR>
          </TBODY>
        </TABLE>
    </CENTER></DIV>
    <table width="100%" border="0" cellspacing="1" cellpadding="1" height="0">
      <tr>
        <td valign="top" height="0">
          <div align="right">
            <form name="form1" method="post" action="reguser/login.php">
              用户名:
              <input type="text" name="user" size="18" class="inputborder">
              密码:
              <input type="password" name="pass" size="12" class="inputborder">
              <input type="submit" name="Submit" value="登 录 !" class="inputborder">
            </form>
          </div>
        </td>
      </tr>
    </table>
    <table cellspacing=0 cellpadding=0 width="100%" align=center border=0 bgcolor="#efefef">
      <tbody>
      <tr>
        <td align=left height=26 valign="top" width="78%" bgcolor="#efefef"><font color="#000000">您的IP:218.76.2.228
          来自:尚未分配 , 操作系统:Windows 2000 ,浏览器:Internet Explorer(IE) 6.0 . <br>
          所有时间均为 北京时间 .现在时间 08:58 AM. </font> </td>
        <td align=left height=26 valign="top" width="22%">
          <div align="center"><img src="images/lflogo.gif" width="88" height="31" border="1"></div>
        </td>
      </tr>
      </tbody>
    </table>
    <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
      <TBODY>
      <TR>
        <TD align=middle height=25 bgcolor="#B84F1D">
          <div align="center"><font color="#FFFFFF">Copyright &copy; 2001<font color="#00FF00">
            <b><font color="#33FFFF">CN0745</font></b></font>.<b><font color="#FFCC00">COM</font></b>
            All rights reserved.怀化在线 版权所有 <BR>
            有任何建议与意见请</font><A
          href="mailto:[email protected]"><B><font color="#FFFFFF">与我们联系</font></B></A>
          </div>
        </TD>
      </TR></TBODY></TABLE>  <?
      mysql_close($conn);
      exit();
      ?>
      </BODY></HTML>
      

  16.   

    login.php<?
     session_start(); include("../conn.php");
     //登陆开始          $sql="select username,userpass from phpbbsuser where username='$user' and userpass='$pass'" ;
              $result=mysql_query($sql,$conn);
              $row=mysql_fetch_array($result);
              if (strlen($row["username"])==0){
              ?>
               <script>
     alert("登录信息有错误,请重新登录!")
     location.href="index.php"
               </script>
              <?
     }
     else{
             session_register($login);
             $login=$row["username"];
             echo session_is_registered($login);
             echo $login;
              ?>
                <script>
       location.href="../index.php"
                </script>
              <?
               }
             mysql_close($conn) or die ("不能关闭数据库,正忙");
             exit();
     ?>
      

  17.   

    是session_register("login");
    而不是 session_register($login);
      

  18.   

    一般我做的时候所注册的SESSION变量和表单提交的变量名字不相同,如:
    $username1=$username;
    session_register("username1");
    这样做好象是为了避免一个错误而这样做的,你可以试一下,因为SESSION 变量注册以后,如果再对他进行编辑,可以有错误!
      

  19.   

    同意Mistruster(弱智d) 所说的,你用session_register($login);实际上是注册了一个名用$login内的值的一个session变量,而不是login变量,如你的$login此时的值为"loginuser",则注册的session变量为loginuser,而其值为空。不信你可以将所有session变量列出来看看!
      

  20.   

    你看看自己的浏览器是不是把COOKIE给关了,
    如果关了的话就可能出现这种情况的。PHP的SESSION有两中实现的方式,一种就是把SESSIONID给发给客户端,
    另一种是把SESSIONID做为页面种每个URL的一部分。
    这是可以设置的。
      

  21.   

    弱智说的:$username1=$username;
    session_register("username1");
    差不多就是session_register时出错了。害我看了那么多代码。累呀。
      

  22.   

    一点建议
    $sql="select username,userpass from phpbbsuser where username='$user' and userpass='$pass'" ;
    $result=mysql_query($sql,$conn);
    $row=mysql_fetch_array($result);
    修改为这样
    $sql="select userpass from phpbbsuser where username='$user'" ;
    $result=mysql_query($sql,$conn);
    $row=mysql_fetch_array($result);
    if($pass == $row[userpass])
        print("success");
    else
        print("fail");
    这中语句
    $sql="select username,userpass from phpbbsuser where username='$user' and userpass='$pass'" ;
    很容易出毛病的
      

  23.   

    检查一下你的服务器的WORKPATH设置,看看是不是你的PHP文件的存放位置!
      

  24.   

    session要在每个文件最开始的时候
    <?php
    session_start();
    session_register('username');
    然后,这个$username就可以用了,''或""都可以,即可以是数组,又可以是普通的
      

  25.   

    你是session_register($username);这样的话,你的session变量名应该是
    $lgphp,再说了,''或""还是不要省掉比较好;还有session可以自己区别不同的用户,不用以$username的值来定义,那样比较乱,新新多嘴了...
      

  26.   

    不知道你用的是不是CSDN关盘上附带的PHP, 那个好像有问题,
    我好像也见过同样的情况, 在下载了最新版本的PHP后一切正常!
      

  27.   

    session_register()函数中的参数是字符串,不是php变量!注册后会得一个与字符串同名的php变量!
      

  28.   

    变量取出要传递时候先赋值给其他一个已经session的变量,就可以了。
      

  29.   

    应该这样写:
    index.php
    <?
    session_start();
    global $username;
    ?>之后就可以直接使用$username了,肯定是你要的值。
      

  30.   

    应该这样写:这是登陆页面!login.php
    <?
    session_start();
    require("../conn.php");
    //登陆开始
    $sql="select username,userpass from phpbbsuser where username='$user' and userpass='$pass'" ;
    $result=mysql_query($sql,$conn);
    $row=mysql_fetch_array($result);
    if (strlen($row["username"])==0){
    ?>
    <script>
    alert("登录信息有错误,请重新登录!")
    location.href="index.php"
    </script>
    <?
    }
    else{
    $username=$user;
    session_register(username);//*********
    ?>
    <script>
    location.href="../index.php"
    </script>
    <?
    mysql_close($conn) or die ("不能关闭数据库,正忙");
    exit();
    }
    ?>登陆成功后,
    index.php
    <?
    echo "欢迎您,";
    if (session_is_registered($username) {
        echo $username;
    }else{
        echo "客人";
    }Good Luck!
      

  31.   

    給分吧session_register("username");不是session_register($username);或者$var_to_reg = 'username';
    session_register($var_to_reg);