mysql_query("set names gb2312"); $code=$_POST['code']; $username=$_POST['username']; //$query="select * from user where name=".$_POST['username'].""; $query="select * from user where password='$code' and name='$username'"; $result=mysql_query($query); $rows=@mysql_num_rows($result);
只是作为一个信号我现在做一个网站,我只负责后台,,做前台的人说要我发回一个验证信息,他得到信息就可以控制网页上显示什么信息了
不管验证通过或不通过,客户端[前台]总要给服务端[程序]发送请求才行吧
当验证通过时你返回ok,至于这个返回的ok他前台页面怎么处理是他的问题了!
用什么语句或什么函数啊,,能不能具体讲一下<?php
//获得数据库
include("connect.php");
//获得前一个页面传来的数据
mysql_query("set names gb2312");
$code=$_POST['code'];
$username=$_POST['username'];
//$query="select * from user where name=".$_POST['username']."";
$query="select * from user where password='$code' and name='$username'";
$result=mysql_query($query);
$rows=@mysql_num_rows($result);
//验证
if($rows==0)
{
echo "用户名或密码错误!";
//header("location: error.php");
}
else {
//成功
echo $username."<br>".'435寝室欢迎您!';
//header("location: indextest22.html");
}
?>这个是我的验证模块,,应该怎么改?
1楼和3楼均是正确的!
如果不用post,也不用跳转get传值
也用不了cookie和sessoin
只能用ajax了这个还是比较难的
<?php
//获得数据库
include("connect.php");
//获得前一个页面传来的数据 mysql_query("set names gb2312");
$code=$_POST['code'];
$username=$_POST['username'];
//$query="select * from user where name=".$_POST['username']."";
$query="select * from user where password='$code' and name='$username'";
$result=mysql_query($query);
$rows=@mysql_num_rows($result);
//验证
if($rows==0)
{
echo "error";
//header("location: error.php"); }
else {
//成功
echo "ok";
//header("location: indextest22.html");
}
?> LZ用的好象是ajax哦,.如果是的话,成功就直接输出ok,这样就可以返回给前台了.