3 回答

TA贡献1818条经验 获得超8个赞
下面是通过ajax发送到php上的局部代码
$username=mysql_escape_string($_POST['username']);
$password=sha1( mysql_escape_string($_POST['password']));
$query_string = "SELECT * FROM `users` WHERE `name`='$username' AND `password`='$password';";
$result = mysql_query($query_string);
if (mysql_num_rows($result) > 0){
//
$_SESSION['username']=$username;
$data = mysql_fetch_row($result);
$_SESSION['company']=$data['4'];
header("location: index.php");
//die();
}
else {
$tip="用户不存在或密码错误";
}

TA贡献1869条经验 获得超4个赞
1 2 3 4 5 6 7 8 9 | $("button").click(function(){ $.get("ajax_login.php",{username:'testname'}, function(result){ if(result){ //判断已经存在 alert('用户名已经存在'); }else{ alert('可以注册'); } }); }); |
- 3 回答
- 0 关注
- 341 浏览
添加回答
举报