大家来看看,session的问题。

xuujie 2001-02-19 09:31:00
<?php
//checkuser.php
/**
* Used to check user login input.
* if successfully get into forum.
* else show error message.
*/
require ("config.inc.php");
$currentUser = new User;
session_start();

$username = StripSlashes($arr_request['username']);
$password = StripSlashes($arr_request['password']);

$err_count = 0;
$err_array = array();

if ($username==null)
{
$err_array[$err_count++] = MSG0001;
}
if (strlen($username)>20)
{
$err_array[$err_count++] = MSG0002;
}
if (hasCNChar($username))
{
$err_array[$err_count++] = MSG0003;
}
if ($password==null)
{
$err_array[$err_count++] = MSG0004;
}
if (strlen($password)>20)
{
$err_array[$err_count++] = MSG0005;
}
$haveError = showErrorMessage($err_count,$err_array);

if (!$haveError)
{
if (checkUser($username,$password))
{
session_register("currentUser");
$currentUser = getUserInfo($username);
$usergroupName = getUserGroupName($currentUser->UserGroupID);

header("Location:main.php");
}
else
{
echo MSG0010."请";showBack(BACK);echo "重试";
exit();
}
}
?>
main.php
<?php
require("config.inc.php");
session_start();
require("checkuser.inc.php");
require("online.php");
beginHTML("论坛");
?>
<table width="777" align="center" cellspacing="0" cellpadding="0" border=1 bordercolor="#A3D0F5">
<tr>
<td colspan="3"><h2 align=center><? echo FORUM_TITLE?></h2></td>
</tr>
<tr>
<th colspan="3">  首页 ||   <? if ($username != "guest") echo "<a href=edituserprofile.php>个人资料</a> ||  "?> <? if ($currentUser->UserGroupID==0) echo "<a href=admin.php>论坛管理</a> ||   ";?><a href="logout.php">退出论坛</a></th>
</tr>
<tr>
<td colspan="3">
<table width="100%" cellspacing="5">
<tr>
<td width=60%> </td>
<td width=30%>现在时间:<?echo getCurrentTime()?></td>
<td width=10%>在线:<font color=red><a href="onlinememberlist.php"><?echo getOnlineNumber()?></a></font> 人</td>
</tr>
</table>
<table width="100%" cellspacing="20">
<tr>
<td>
<? if ($username != "guest") include("userinfo.inc.php"); else echo "<marquee>欢迎你来本论坛!</marquee>"?>
</td>
</tr>
<tr>
<td>
<? require("modulelist.inc.php")?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<?
endHTML();
?>
user对象已经在config.inc.php文件里定义了。为什么,在linux+php4.0.3pl1下还有问题?说要在session_start()之前define user.
...全文
113 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
SimonDW 2001-02-23
  • 打赏
  • 举报
回复
config.inc.php?
soff 2001-02-20
  • 打赏
  • 举报
回复
把session_start()放到最前面试试?

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧