免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2054 | 回复: 4
打印 上一主题 下一主题

[SESSION] session跨页传递的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-06-04 14:11 |只看该作者 |倒序浏览
index.htm
<form name="form1" id="form1" method="post" action="login_do.php">
          <p>用户名:
            <input name="username" type="text" id="username" size="20" />密码 :
            <input name="password" type="password" id="password" value="" size="16" />
            <input type="submit" name="Submit" value="提交" />
          </p>
          </form>

login_do.php
<?php
//set server access varables
$host = "localhost";
$user = "root";
$pass = "";
$db = "bylw";
$connection = mysql_connect($host, $user, $pass);
mysql_query("SET NAMES 'GBK'");
mysql_select_db($db) or die ("unable to connect !");
session_start();
session_register(student_name);
session_register(teacher_name);
$username=$_POST['username'];
$password=$_POST['password'];
$exec= "select * from login where user_id='".$username."'";
$result=mysql_query($exec);
$rs=mysql_fetch_object($result);
if($rs->password==$password and $rs->pd=='teaher')
{
$teacher_name=$username;

header ("Location: jiaoshi.php");
}
elseif ($rs->password==$password and $rs->pd=='student')
{

$student_name=$username;
header ("Location:student.php");
}
else
    {
      echo "<script>alert('用户名或密码错误!');location.href='index.htm';</script>";
    }
  ?>

student.php
    <?php
        session_start();
session_register(student_name);
session_register(teacher_name);
       
        echo '姓名:'.$student_name.'<br>';
   ?>

错误信息:

Not Found
The requested URL /bylw/function.session-start was not found on this server.
我是php新手,看了好久没明白错在哪?请高手指教.

[ 本帖最后由 HonestQiao 于 2006-6-4 21:59 编辑 ]

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-04-13 06:20:00
2 [报告]
发表于 2006-06-04 15:27 |只看该作者
http://php.winet.cn/function.session-start.php

不是跨页面传递的问题,

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-04-13 06:20:00
3 [报告]
发表于 2006-06-04 15:29 |只看该作者

论坛徽章:
0
4 [报告]
发表于 2006-06-04 22:58 |只看该作者

session跨页传递的问题

thanks;

又有新的问题了,
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in D:\usr\Apache\Apache2\htdocs\login.php on line 21

login.php


<?
session_start();
session_register(student_name);
session_register(teacher_id);
session_register(student_id);
?>

<?php
//set server access varables
$host = "localhost";
$user = "root";
$pass = "";
$db = "bylw";
$connection = mysql_connect($host, $user, $pass);
mysql_query("SET NAMES 'GBK'");
mysql_select_db($db) or die ("unable to connect !");
$user_id=$_POST['username'];
$password=$_POST['password'];
$exec= "select * from login where user_id=.$user_id. and password=.$password.";
$result=mysql_query($exec);
$rs=mysql_fetch_object($result);
$username=$rs->username;
if($rs->password==$password and $rs->pd=='teaher')
{
$teacher_name=$username;
$teacher_id=$user_id;


header ("Location: jiaoshi.htm");
}
elseif ($rs->password==$password and $rs->pd=='student')
{

$student_name=$username;
$student_id=$user_id;
header ("Location:student.htm");
}
else
    {
      echo "<script>alert('用户名或密码错误!');location.href='index.php';</script>";
    }
  ?>

论坛徽章:
0
5 [报告]
发表于 2006-06-04 23:11 |只看该作者

session跨页传递的问题

我是初学者,大家不要笑话哦.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP