sessio问题 PHPSESSID=8d6f9f7a734e3098abb4cddcadd61ab5有这些正常啊服务器怎么个不行法?有没出错提示 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你看下程序<?php//index page use /template/index.htm as its HTML templaterequire_once("config.inc.php");require_once("class/template.inc.php");require_once("class/mysql.inc.php");require_once("class/item.inc.php");require_once("class/member.inc.php");session_start();if (!isset($HTTP_SESSION_VARS["member"])){ // the user has not login and can't post message $msg = "请您在发布信息之前先登录."; $msg .= "<br><br>如果您还没有注册,点击<a href='reg.php'><font color='red'>这里</font></a>注册"; $tpl = new template($TEMPLATE_DIR); $tpl->set_file("error", "login.htm"); $tpl->set_var("data", $msg); $tpl->pparse("out", "error"); exit();}if (isset($HTTP_POST_VARS["action"]) && $HTTP_POST_VARS["action"] == "post"){ //form has been submitted //initialize the class object $m = $HTTP_SESSION_VARS['member']; $db = & new mysql(); $item = & new item($db); $id = ""; $brand = $HTTP_POST_VARS["brand"]; $type = $HTTP_POST_VARS["type"]; $others = $HTTP_POST_VARS["others"]; $mode = $HTTP_POST_VARS["mode"]; $poster = $m->user_name; $postime = date("Y-m-d H:i:s"); $res = $item->add($id, $brand, $type, $poster, $postime, $others, $mode); if ($res) { // add item success $msg = "<b>发布成功!</b>."; $mode=='sale'?$info="供方信息":$info="求购信息"; $msg .= "<br><br>您可以到".$info."里查看您刚才发表的信息.<br>"; $msg .= "<br><a href='index.php'>返回首页</a>"; $tpl = new template($TEMPLATE_DIR); $tpl->set_file("error", "msg.htm"); $tpl->set_var("msg", $msg); $tpl->pparse("out", "error"); } else { // add item failed $msg = "<b>发布失败!</b>."; $msg .= "<br><br>服务器在处理数据时出错,请重新发布您的信息.<br>"; $msg .= "<br><a href='index.php'>返回首页</a>"; $tpl = new template($TEMPLATE_DIR); $tpl->set_file("error", "msg.htm"); $tpl->set_var("data", $msg); $tpl->pparse("out", "error"); }}else{ // no submit ,echo the post form //output use template $tpl = new template($TEMPLATE_DIR); $tpl->set_file('post', 'post.htm'); $tpl->set_var(array('bulletin' => nl2br($BULLETIN_DATA), 'help' => nl2br($HELP_DATA), )); $tpl->pparse('output', 'post');}?>现在的问题是登录以后也不能显示发表文章的表单或者发表以后不显示成功信息,还是显示用户末登录的信息。你可以去printer.51.net/post.php 试一下给你个用户 stone 密码是format 解决了。把isset($HTTP_SESSION_VARS["member"])改成session_is_register("member")就行了。我还是不知道为什么是不是和register global 的设置有关?谁能讲一下这两用法的区别? 如果客户端关闭了cookie,PHP会通过url来实现session 是因为session_is_register()记下了session的值。 php 如何显示所属类别 页面在ie下空白火狐下正常 求解 关于if判断问题! curl抓取不到页面内容 再提一个问题? php利用flash上传,IE会死掉 问题之框架。。。 PHP,21世纪的霸主 限制手机短信验证发送次数 如何用php装中文字符串编译成不重复的代码串 请问这个句子在my SQL下为什么不能执行啊 我最近在学习怎么用MVC实现PHP的网站结构,我把源码发表一下,大家看看。请多指教
//index page use /template/index.htm as its HTML template
require_once("config.inc.php");
require_once("class/template.inc.php");
require_once("class/mysql.inc.php");
require_once("class/item.inc.php");
require_once("class/member.inc.php");session_start();
if (!isset($HTTP_SESSION_VARS["member"]))
{ // the user has not login and can't post message
$msg = "请您在发布信息之前先登录.";
$msg .= "<br><br>如果您还没有注册,点击<a href='reg.php'><font color='red'>这里</font></a>注册";
$tpl = new template($TEMPLATE_DIR);
$tpl->set_file("error", "login.htm");
$tpl->set_var("data", $msg);
$tpl->pparse("out", "error");
exit();
}
if (isset($HTTP_POST_VARS["action"]) && $HTTP_POST_VARS["action"] == "post")
{ //form has been submitted
//initialize the class object
$m = $HTTP_SESSION_VARS['member'];
$db = & new mysql();
$item = & new item($db);
$id = "";
$brand = $HTTP_POST_VARS["brand"];
$type = $HTTP_POST_VARS["type"];
$others = $HTTP_POST_VARS["others"];
$mode = $HTTP_POST_VARS["mode"];
$poster = $m->user_name;
$postime = date("Y-m-d H:i:s");
$res = $item->add($id, $brand, $type, $poster, $postime, $others, $mode);
if ($res)
{ // add item success
$msg = "<b>发布成功!</b>.";
$mode=='sale'?$info="供方信息":$info="求购信息";
$msg .= "<br><br>您可以到".$info."里查看您刚才发表的信息.<br>";
$msg .= "<br><a href='index.php'>返回首页</a>";
$tpl = new template($TEMPLATE_DIR);
$tpl->set_file("error", "msg.htm");
$tpl->set_var("msg", $msg);
$tpl->pparse("out", "error");
}
else
{ // add item failed
$msg = "<b>发布失败!</b>.";
$msg .= "<br><br>服务器在处理数据时出错,请重新发布您的信息.<br>";
$msg .= "<br><a href='index.php'>返回首页</a>";
$tpl = new template($TEMPLATE_DIR);
$tpl->set_file("error", "msg.htm");
$tpl->set_var("data", $msg);
$tpl->pparse("out", "error");
}
}
else
{ // no submit ,echo the post form
//output use template
$tpl = new template($TEMPLATE_DIR);
$tpl->set_file('post', 'post.htm');
$tpl->set_var(array('bulletin' => nl2br($BULLETIN_DATA),
'help' => nl2br($HELP_DATA),
));
$tpl->pparse('output', 'post');
}?>现在的问题是登录以后也不能显示发表文章的表单或者发表以后不显示成功信息,还是显示
用户末登录的信息。
你可以去printer.51.net/post.php 试一下
给你个用户 stone
密码是format
把isset($HTTP_SESSION_VARS["member"])
改成session_is_register("member")
就行了。
我还是不知道为什么
是不是和register global 的设置有关?
谁能讲一下这两用法的区别?
记下了session的值。