php+js+mysql设计的仿webQQ-<4>登陆和注册
来源:互联网 发布:网络畅销小说排行榜 编辑:程序博客网 时间:2024/06/05 11:10
<6>登陆验证
Js代码
function checkLogin(){var xmlhttp;if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();if(xmlhttp.overrideMimeType) {//设置MIME类别 xmlhttp.overrideMimeType("text/xml"); } }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } var url="checkLogin.php?username="+document.getElementById("username").value+"&pwd="+document.getElementById("pwd").value;//把用户名和密码传到checkLogin.php进行验证 xmlhttp.open("GET",url,true);xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("error5").innerHTML="<font color=red size=2px>"+xmlhttp.responseText+"</font>" ;if(xmlhttp.responseText=="登录成功") { window.location.href="myWebChat.php"; //验证成功后跳转到自己的主页 } } } xmlhttp.send(null);}
PHP代码
<?phpheader('Content-Type:text/html;charset=GB2312');include("conn.php");$username=$_GET["username"];$pwd=$_GET["pwd"];if($username==null||$pwd==null) { echo "用户名或密码不能为空!"; }else { $sql="select * from user where email='$username'"; $result = mysql_query($sql); $num=mysql_num_rows($result); if($num>0) { $row=mysql_fetch_array($result);if($pwd==$row["pwd"]) { @session_start(); $_SESSION["email"]=$username; $statesql="update user set state='在线' where email='".$username."'"; //当用户成功登陆后把状态写入数据库 mysql_query($statesql); echo "登录成功"; }else { echo "用户名或密码错误!"; }} else { echo "用户名或密码错误!";} }?>
<7>注册验证
Js代码
function checkRegistration(){var xmlhttp;if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();if(xmlhttp.overrideMimeType) {//设置MIME类别 xmlhttp.overrideMimeType("text/xml"); } }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } var url="checkRegistration.php?email="+document.getElementById("email").value+"&nickname="+document.getElementById("nickname").value+ "&pwd="+document.getElementById("password2").value+"&sex="+document.getElementById("sex").value+ "&month="+document.getElementById("month").value+"&day="+document.getElementById("day").value+ "&error1="+document.getElementById("error1").innerHTML+"&error2="+document.getElementById("error2").innerHTML+ "&error3="+document.getElementById("error3").innerHTML+"&error4="+document.getElementById("error4").innerHTML; xmlhttp.open("GET",url,true);xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("error6").innerHTML="<font color=green size=2px>"+xmlhttp.responseText+"</font>"; if(xmlhttp.responseText=="注册成功") { window.location.href="myWebChat.php"; } } } xmlhttp.send(null);}
PHP代码
<?phpheader('Content-Type:text/html;charset=GB2312');$error1=$_GET["error1"];$error2=$_GET["error2"];$error3=$_GET["error3"];$error4=$_GET["error4"];$error1=strlen($error1);$error2=strlen($error2);$error3=strlen($error3);$error4=strlen($error4);if(($error1==49&&$error2==49&&$error3==49&&$error4==53)||($error1==43&&$error2==43&&$error3==43&&$error4==47)) //仅适合IE和Chrome { $email=$_GET["email"];$nickname=$_GET["nickname"];$pwd=$_GET["pwd"];$sex=$_GET["sex"];$month=$_GET["month"];$day=$_GET["day"];include("conn.php");$sql="insert into user values('$email','$pwd','$nickname','$sex','$month','$day','在线')";$result=mysql_query("$sql");if($result) { @session_start(); $_SESSION["email"]=$email; echo "注册成功"; } }else { echo "请完善注册信息!"; }?>
注册验证自认为写的很差,欢迎拍砖!(未完待续)
- php+js+mysql设计的仿webQQ-<4>登陆和注册
- php+js+mysql设计的仿webQQ-<1>邮箱验证
- php+js+mysql设计的仿webQQ-<2>其他验证
- php+js+mysql设计的仿webQQ-<6>JS创建聊天窗口
- php+js+mysql设计的仿webQQ-<5>IM窗体的实现
- php+js+mysql设计的仿webQQ-<7>聊天消息的发送与刷新
- php+js+mysql设计的仿webQQ-<3>月份天数随月份改变
- PHP登陆注册页面的设计感悟
- 【前端】javascript仿windows和webqq的感想及心得
- PHP¥MYSQL注册登陆数据的一些处理
- 高仿Android QQ2012登陆界面和注册界面
- 高仿Android QQ2012登陆界面和注册界面
- 高仿Android QQ2012登陆界面和注册界面
- 高仿Android QQ2012登陆界面和注册界面 hierarchyviewer
- 高仿Android QQ2012登陆界面和注册界面
- 高仿Android QQ2012登陆界面和注册界面
- 高仿Android QQ2012登陆界面和注册界面
- Android PHP Okhttp3模拟登陆和注册
- 基于ExtJS的呼叫中心系统
- 安全测试checklist
- Android培训班(107)start_kernel函数4
- 从printf谈可变参数函数的实现
- 神经网络学习
- php+js+mysql设计的仿webQQ-<4>登陆和注册
- 工作笔录1
- Apache NIO 框架 Mina 使用中出现 too many open files 问题的解决办法
- 工作笔录2
- Qt_Project_Update_Platform
- jaspereport 报表
- FFF Warm Up Contest 14 - CERC 2011 [iSea]
- Javascript中出现内存泄露的主要原因是什么
- 我最喜欢的10条编程语录