mysql中公共字段被称为_将MySql中的表与一个公共字段连接,但公共字段的值不同...

会话和包含功能给出:

session_start();

include("config.php");

if(isset($_POST['T_UserName']) && isset($_POST['T_Password']) && !empty($_POST['T_UserName']) && !empty($_POST['T_Password']))

{

从表单发送的用户名和密码:

$T_UserName=$_POST['T_UserName'];

$T_Password=$_POST['T_Password'];

保护MySQL注入:

$T_UserName = stripslashes($T_UserName);

$T_Password = stripslashes($T_Password);

$T_UserName= mysql_real_escape_string($T_UserName);

$T_Password = mysql_real_escape_string($T_Password);

$sql="SELECT * FROM login WHERE username='$T_UserName' and password='$T_Password'"; $result=mysql_query($sql);

Mysql_num_row正在计算表行:

$count=mysql_num_rows($result);

如果结果与$ T_UserName和$ T_Password匹配,则表行必须为1行:

if($count==1)

{

注册$ T_UserName,$ T_Password并重定向到文件“correspindex.php”:

session_register("T_UserName");

session_register("T_Password");

重定向到错误页面或显示错误消息然后:

if(isset($_POST['emp_role'])

{

$userinfo = mysql_fetch_assoc($sql);

$emp_role = $userinfo['emp_role'];

if($emp_role == 1)

{

header("location:corrrespondindex.php");

}

elseif($emp_role == 2 )

{

header("location:principalindex.php");

}

elseif($emp_role == 3)

{

header("location:staffindex.php");

}

closes out if the user DOES exist:

header("location:loginhome.php");

}

else

{

echo "Wrong Username or Password";

}

}

}

php is closed

this is the php code im getting so many error

i create 1table with id,username,password and role(ENUM,values as'1','2','3' –

any else shud i do in the code???

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值