<?php
error_reporting(0);
$mysql_servername ="10.4.250.20";
$mysql_username = "hr";
$mysql_password ="946138";
$mysql_database ="hr"; //数据库名
if(isset($_POST['Submit'])){
$mssql_connect($mysql_servername , $mysql_username , $mysql_password) or die("数据库连接错误!");
mssql_select_db($mysql_database);
mssql_query("SET NAMES 'gbk'");
$tname=$_POST['txt_user'];
$tpassowrd=$_POST['txt_password'];
if(empty($tname))
{
echo "<script language=javascript>alert('用户名不能为空');history.back();</script>";
exit;
}
$sql =" select * from Pip_Staff_S where cStaffID ='$tname' and cDoorLock='$tpassowrd'";
echo $sql;
$res = mssql_query($sql);
$rows = mssql_num_rows($res);
echo $rows;
if($rows)
{
echo "<script langrage=javascript>alert('恭喜您登陆成功')</script>";
echo "<script>window.location.href='Index_STR.php';</script>";
exit;
}
else
{
echo "<script language=javascript>alert('用户名密码错误');history.back();</script>";
}
}
?>Html 代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>STR</title>
<style type="text/css">
<!--
.STYLE1 { font-size: 24px;
font-weight: bold;
}
-->
</style>
</head><body>
<form id="form1" name="form1" method="post" action="login1.php">
<table width="894" height="351" border="0">
<tr>
<td width="270" height="110"> </td>
<td width="82"> </td>
<td width="179"><span class="STYLE1">欢迎登录STR</span></td>
<td width="157"> </td>
<td width="172"> </td>
</tr>
<tr>
<td height="36"> </td>
<td>User ID:</td>
<td><label>
<input name="txt_user" type="text" id="txt_user" />
</label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="57"> </td>
<td>Pass Word:</td>
<td><input name="txt_password" type="password" id="txt_password" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="63"> </td>
<td><label>
<div align="right">
<input type="submit" name="Submit" value="登 录" />
</div>
</label></td>
<td><label>
<input type="submit" name="Submit2" value="注 册" onClick="document.location.href='Register.php'"/>
</label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="17"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>
数据库用户名和密码都是正确的为什么我输入正确的用户名和密码是 页面直接跳转到 "login1.php"
应该是跳转到"Index_STR.php".
我连接的是msssql,请问是什么愿?
error_reporting(0);
$mysql_servername ="10.4.250.20";
$mysql_username = "hr";
$mysql_password ="946138";
$mysql_database ="hr"; //数据库名
if(isset($_POST['Submit'])){
$mssql_connect($mysql_servername , $mysql_username , $mysql_password) or die("数据库连接错误!");
mssql_select_db($mysql_database);
mssql_query("SET NAMES 'gbk'");
$tname=$_POST['txt_user'];
$tpassowrd=$_POST['txt_password'];
if(empty($tname))
{
echo "<script language=javascript>alert('用户名不能为空');history.back();</script>";
exit;
}
$sql =" select * from Pip_Staff_S where cStaffID ='$tname' and cDoorLock='$tpassowrd'";
echo $sql;
$res = mssql_query($sql);
$rows = mssql_num_rows($res);
echo $rows;
if($rows)
{
echo "<script langrage=javascript>alert('恭喜您登陆成功')</script>";
echo "<script>window.location.href='Index_STR.php';</script>";
exit;
}
else
{
echo "<script language=javascript>alert('用户名密码错误');history.back();</script>";
}
}
?>Html 代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>STR</title>
<style type="text/css">
<!--
.STYLE1 { font-size: 24px;
font-weight: bold;
}
-->
</style>
</head><body>
<form id="form1" name="form1" method="post" action="login1.php">
<table width="894" height="351" border="0">
<tr>
<td width="270" height="110"> </td>
<td width="82"> </td>
<td width="179"><span class="STYLE1">欢迎登录STR</span></td>
<td width="157"> </td>
<td width="172"> </td>
</tr>
<tr>
<td height="36"> </td>
<td>User ID:</td>
<td><label>
<input name="txt_user" type="text" id="txt_user" />
</label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="57"> </td>
<td>Pass Word:</td>
<td><input name="txt_password" type="password" id="txt_password" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="63"> </td>
<td><label>
<div align="right">
<input type="submit" name="Submit" value="登 录" />
</div>
</label></td>
<td><label>
<input type="submit" name="Submit2" value="注 册" onClick="document.location.href='Register.php'"/>
</label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="17"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>
数据库用户名和密码都是正确的为什么我输入正确的用户名和密码是 页面直接跳转到 "login1.php"
应该是跳转到"Index_STR.php".
我连接的是msssql,请问是什么愿?
解决方案 »
- 我用下面程序怎么插入不进去数据库?求高手解答
- php读取unix时间戳出现了问题
- WordPress中,初始画面怎么是他不显示首页?
- 请教一条SQL语句
- 正则高手进
- 你们的金额字段设计的是什么数据类型呀,为何我的金额字段合计出来有很多小数位呀?Please help me!
- 刚开发完成一个MySQL数据库动态创建系统,比phpMyAdmin要灵活方便多了,如果想要,跟我联系吧
- mysql_fetch_array(): 出错问题
- 如何用header设置cache的private,must-revalidate?不用session_cache_limiter。
- 在读取一条记录的时候怎么样获取这条记录的下一条的记录啊?
- 新手求救,javascript问题
- eclipse里用来调试php的php script与php web page有什么不同吗
mssql是连接Microsoft SQL Server数据库。
echo "<script>window.location.href='Index_STR.php';</script>";
exit; index_str.php 里面有没有判断session,cookie什么的?
是不是index_str.php页面判断cookies为空了.
這兩個地方的問題...
不懂.
if($rows)
{
echo "<script langrage=javascript>alert('恭喜您登陆成功')</script>";
echo "<script>window.location.href='Index_STR.php';</script>";
exit;
}
else
{
echo "<script language=javascript>alert('用户名密码错误');history.back();</script>";
}运行到这段代码 就会有对话框弹出来哦?但不知道为什么会直接运行到 "login1.php“页面中??还有,我把window.location.href='Index_STR.php' 换成连接到其他页面去,
运行后他还是连接到"login1.php“页面中???
我用vb.net连接是成功的。。现在是要用php去连。
???
为什么是:$mssql_connect
应该是:mssql_connect调试程序时不应关闭错误显示!
即。不能 error_reporting(0);
而应该 error_reporting(E_ALL);
至少也是 error_reporting(E_ALL & ~E_NOTICE);