<?php
session_start();
function err_output($errstr="未知错误!"){
echo "<p align=center><font color=red size=4>
<b>$errstr<br></b>请点击此处<a href=javascript:history.go(-1);>返回</a>
</font></p>";
exit();
}
$db=mysql_connect("localhost")
or err_output("无法连接数据库!");
mysql_select_db("superymq")
or err_output("无法选择数据库!");if($login){
if(empty($name)||(empty($pwd))){
err_output("用户名或密码不能为空!");
}
switch($radiobutton){
case'manager':
$result=mysql_query("select*from manager where name='$name'");
if(mysql_num_rows($result)!=1){
err_output("用户不存在!");
}
else{
$arrUser=mysql_fetch_array($result);
if($arrUser["password"]!=$pwd){
err_output("密码错误!");
}
else{
session_register("name","password");
$name=$result;
$password=$arrUser["password"];
header("Location: ../1.htm");
}
}
mysql_close($db);
break;
}
switch($radiobutton){
case'user':
$result=mysql_query("select*from user where name='$name'");
if(mysql_num_rows($result)!=1){
err_output("用户不存在!");
}
else{
$arrUser=mysql_fetch_array($result);
if($arrUser["password"]!=$pwd){
err_output("密码错误!");
}
else{
session_register("name","password");
$name=$result;
$password=$arrUser["password"];
header("Location: ../2.htm");
}
}
mysql_close($db);
break;
}
}
?>
session_start();
function err_output($errstr="未知错误!"){
echo "<p align=center><font color=red size=4>
<b>$errstr<br></b>请点击此处<a href=javascript:history.go(-1);>返回</a>
</font></p>";
exit();
}
$db=mysql_connect("localhost")
or err_output("无法连接数据库!");
mysql_select_db("superymq")
or err_output("无法选择数据库!");if($login){
if(empty($name)||(empty($pwd))){
err_output("用户名或密码不能为空!");
}
switch($radiobutton){
case'manager':
$result=mysql_query("select*from manager where name='$name'");
if(mysql_num_rows($result)!=1){
err_output("用户不存在!");
}
else{
$arrUser=mysql_fetch_array($result);
if($arrUser["password"]!=$pwd){
err_output("密码错误!");
}
else{
session_register("name","password");
$name=$result;
$password=$arrUser["password"];
header("Location: ../1.htm");
}
}
mysql_close($db);
break;
}
switch($radiobutton){
case'user':
$result=mysql_query("select*from user where name='$name'");
if(mysql_num_rows($result)!=1){
err_output("用户不存在!");
}
else{
$arrUser=mysql_fetch_array($result);
if($arrUser["password"]!=$pwd){
err_output("密码错误!");
}
else{
session_register("name","password");
$name=$result;
$password=$arrUser["password"];
header("Location: ../2.htm");
}
}
mysql_close($db);
break;
}
}
?>
那你再看看其他的特别那个session,我没用过
我想在首页登陆区在登陆后显示"$name你好"并且原来登陆提交按钮等等全无,怎么实现?
echo "用户名或密码不能为空";
echo "<br><a href=javascript:history.back(1)>点击这里返回</a>";
exit;
endif;