求php代码例子 谁能给我一个php代码ajax的例子,我现在想学习php,是web方面请大家帮忙提供点示例谢谢了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <? session_start(); $myCxmis = new Cxmis; if($mysubmit =="确定"){ $result = $myCxmis->register($username,$password); if($result==2){ $uid=$username; session_register('uid'); ?><script language="javascript">alert("注册成功");window.location='ywsljj.php';</script><? }else if($result==1){?><script language="javascript">alert("此用户名已经存在,请重新注册");window.location='javascript:history.back(-1)';</script><? }else{?><script language="javascript">alert("注册失败,请重新注册");window.location='javascript:history.back(-1)';</script><? }}else {?><html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title></title></head><script language="Javascript" src="/script/checkpassword.js"></script><script language="Javascript" src="/script/ajaxreg.js"></script><body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"><div align="left"> <table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1"><?require("./include/top.inc");?> <tr> <td align="left" valign="top"> <table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top" width="235"> <table border="0" width="100%" id="table19" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top"> </td> </tr> <tr> <td> <img border="0" src="images/zjcx_ml_11_01.gif" width="235" height="166"></td> </tr> </table> </td> <td align="left" valign="top"> <table border="0" width="100%" id="table14" cellspacing="0" cellpadding="0"> <tr> <td width="22"> <img border="0" src="images/zjcx_07_01.gif" width="22" height="16"></td> <td background="images/zjcx_07_02.gif"> <img border="0" src="images/zjcx_07_02.gif" width="745" height="16"></td> </tr> <tr> <td background="images/zjcx_07_03.gif" height="380" width="22"> <img border="0" src="images/zjcx_07_03.gif" width="22" height="50"></td> <td align="left" valign="top"> <table border="0" width="100%" id="table15" cellspacing="0" cellpadding="0"> <tr> <td> <p align="center">帐 号 注 册 <!--img border="0" src="images/zjcx_07_04_01.gif" width="745" height="35"--></td> </tr> <tr> <td> <table border="0" width="100%" id="table16" cellspacing="0" cellpadding="0"> <tr> <td width="363"> <img border="0" src="images/zjcx_07_08_01.gif" width="363" height="17"></td> <td background="images/zjcx_07_08_02.gif"> <img border="0" src="images/zjcx_07_08_02.gif" width="9" height="17"></td> <td width="373"> <img border="0" src="images/zjcx_07_08_03.gif" width="373" height="17"></td> </tr> </table> </td> </tr> <tr> <td align="center"> <table border="0" width="98%" id="table18" cellspacing="0" cellpadding="0"> <tr> <td> <form name=reg method=post action="/register.php" onsubmit="return checkpwd(this)"><table border="0" cellspacing="1" cellpadding="5" bgcolor="#9ad0eb"><table border="0" cellspacing="1" cellpadding="5" bgcolor="#9ad0eb" width="100%"><tr bgcolor="#e4f2fa"> <td colspan=3>帐号注册</td></tr>( * 为必填项)<tr bgcolor="#e4f2fa"> <td > <div align="center">用户名<font color="#FF0000">*</font></div> </td> <td > <input type="text" name="username" id="username" size="25" maxlength="15" onBlur="return usercheck('check')"> </td> <td align="left" bgcolor="#FFFFFF"><!--input type=button value='检查用户名' onclick="return usercheck('check')"--><span id="check"> 3-16个字符,英文小写、汉字、数字、最好不要全部是数字。</span></td> </tr> <tr bgcolor="#e4f2fa"> <td > <div align="center">密码<font color="#FF0000">*</font></div> </td> <td > <input type="password" name="password" id="userpwd" onBlur="pwdcheck('pwd')"> </td> <td align="left" bgcolor="#FFFFFF" id="pwd"> 密码字母有大小写之分。6-16位(包括6、16),限用英文、数字。</td> </tr> <tr bgcolor="#e4f2fa"> <td > <div align="center">确认密码<font color="#FF0000">*</font></div> </td> <td > <input type="password" name="checkpassword" id="reuserpwd" onBlur="pwdrecheck('repwd')"> </td> <td align="left" bgcolor="#FFFFFF" id="repwd"> 请再次输入登录密码。</td> </tr><tr bgcolor="#e4f2fa"><td colspan=3 align="center"><input type="submit" name=mysubmit value="确定"><input type=reset value="重填"></td></tr></table></form> <!--文字内容结束--></td> </tr> </table> </td> </tr> <tr> <td> <table border="0" width="100%" id="table17" cellspacing="0" cellpadding="0"> <tr> <td width="363"> <img border="0" src="images/zjcx_07_08_01.gif" width="363" height="17"></td> <td background="images/zjcx_07_08_02.gif"> <img border="0" src="images/zjcx_07_08_02.gif" width="9" height="17"></td> <td width="373"> <img border="0" src="images/zjcx_07_08_03.gif" width="373" height="17"></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr><?require("./include/bottom.inc");?> </table></div></body></html><?}$myCxmis->Destroy();?> ajaxreg.js代码如下:var http_request=false; function send_request(url){//初始化,指定处理函数,发送请求的函数 http_request=false; //开始初始化XMLHttpRequest对象 if(window.XMLHttpRequest){//Mozilla浏览器 http_request=new XMLHttpRequest(); if(http_request.overrideMimeType){//设置MIME类别 http_request.overrideMimeType("text/xml"); } } else if(window.ActiveXObject){//IE浏览器 try{ http_request=new ActiveXObject("Msxml2.XMLHttp"); }catch(e){ try{ http_request=new ActiveXobject("Microsoft.XMLHttp"); }catch(e){} } } if(!http_request){//异常,创建对象实例失败 window.alert("创建XMLHttp对象失败!"); return false; } http_request.onreadystatechange=processrequest; //确定发送请求方式,URL,及是否同步执行下段代码 http_request.open("GET",url,true); http_request.send(null); } //处理返回信息的函数 function processrequest(){ var mess if(http_request.readyState==4){//判断对象状态 if(http_request.status==200){//信息已成功返回,开始处理信息 if(http_request.responseText=='exist') mess="<font color=red>此用户名已经存在,请更换用户名!</font>"; else if(http_request.responseText=='ok') mess="<font color=red>此用户名可以注册</font>"; else if(http_request.responseText=='right') mess="<font color=red>旧密码正确</font>"; else if(http_request.responseText=='error') mess="<font color=red>旧密码不正确</font>"; document.getElementById(reobj).innerHTML=mess; } else{//页面不正常 alert("您所请求的页面不正常!"); } } } function usercheck(obj){ var f=document.reg; var username=f.username.value; if(username==""){ document.getElementById(obj).innerHTML=" <font color='#ff0000'>用户名不能为空!</font>"; //f.username.focus(); //return false; } else if(username.replace(/[^\x00-\xff]/g,'##').length>16){ document.getElementById(obj).innerHTML=" <font color=red>用户名长度不能大于16位(汉字不能超过8个)!</font>"; //f.userpwd.focus(); return false; } else{ document.getElementById(obj).innerHTML="正在读取数据..."; send_request('checkuserreg.php?username='+username); reobj=obj; } } function userpwdcheck(obj){ var f=document.reg; var oldpassword=f.oldpassword.value; if(oldpassword==""){ document.getElementById(obj).innerHTML=" <font color='#ff0000'>旧密码不能为空!</font>"; //f.username.focus(); //return false; } else{ document.getElementById(obj).innerHTML="正在读取数据..."; send_request('checkuserpwd.php?oldpassword='+oldpassword); reobj=obj; } } function pwdcheck(obj){ var f=document.reg; var pwd=f.userpwd.value; if(pwd==""){ document.getElementById(obj).innerHTML=" <font color=red>用户密码不能为空!</font>"; //f.userpwd.focus(); return false; } else if(f.userpwd.value.length<6){ document.getElementById(obj).innerHTML=" <font color=red>密码长度不能小于6位!</font>"; //f.userpwd.focus(); return false; } else{ document.getElementById(obj).innerHTML=" <font color=red>密码符合要求!</font>"; } } function pwdrecheck(obj){ var f=document.reg; var repwd=f.reuserpwd.value; if (repwd==""){ document.getElementById(obj).innerHTML=" <font color=red>请再输入一次密码!</font>"; //f.reuserpwd.focus(); return false; } else if(f.userpwd.value!=f.reuserpwd.value){ document.getElementById(obj).innerHTML=" <font color=red>两次输入的密码不一致!</font>"; //f.reuserpwd.focus(); return false; } else{ document.getElementById(obj).innerHTML=" <font color=red>密码输入正确!</font>"; } } 本人是初学php,发这贴是为了帮人找资料.请大家多多发言 http://hi.baidu.com/jroam/blog/item/0df478f4087778daf3d385c1.html 给个网址你可以参考一下! http://download.csdn.net/source/1329125这里有一些Ajax入门知识 有人用PHP开发过移动MAS接口吗? 关于正则表达式 shopex里面添加的内容 在ie8等其他浏览器都很正常 在ie6下确不正常 网站后台统计功能怎么实现【在线等高手】 如何修改被序列化的数组? 织梦 求一份YYUC框架文件和帮助文档 求高人解密PHP代码 合并的数组怎么分开? php 对接java的soap 以xml传参报“未将对象引用设置到对象的实例” 有大神帮忙看看么 有谁可卖访taobao网的网站源码销售 急~~!!!!!!!!!!PHP文件上传超过2M文件时出现错误,提示FILEDATA错误。<b>Notice</b>: Undefined index: Filedata
session_start();
$myCxmis = new Cxmis;
if($mysubmit =="确定"){
$result = $myCxmis->register($username,$password);
if($result==2){
$uid=$username;
session_register('uid');
?>
<script language="javascript">
alert("注册成功");
window.location='ywsljj.php';
</script>
<?
}else if($result==1){
?>
<script language="javascript">
alert("此用户名已经存在,请重新注册");
window.location='javascript:history.back(-1)';
</script>
<?
}else{
?>
<script language="javascript">
alert("注册失败,请重新注册");
window.location='javascript:history.back(-1)';
</script>
<?
}}else {
?>
<html><head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head>
<script language="Javascript" src="/script/checkpassword.js"></script>
<script language="Javascript" src="/script/ajaxreg.js"></script>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"><div align="left">
<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1"><?
require("./include/top.inc");
?>
<tr>
<td align="left" valign="top">
<table border="0" width="100%" id="table3" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top" width="235">
<table border="0" width="100%" id="table19" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top">
</td>
</tr>
<tr>
<td>
<img border="0" src="images/zjcx_ml_11_01.gif" width="235" height="166"></td>
</tr>
</table>
</td>
<td align="left" valign="top">
<table border="0" width="100%" id="table14" cellspacing="0" cellpadding="0">
<tr>
<td width="22">
<img border="0" src="images/zjcx_07_01.gif" width="22" height="16"></td>
<td background="images/zjcx_07_02.gif">
<img border="0" src="images/zjcx_07_02.gif" width="745" height="16"></td>
</tr>
<tr>
<td background="images/zjcx_07_03.gif" height="380" width="22">
<img border="0" src="images/zjcx_07_03.gif" width="22" height="50"></td>
<td align="left" valign="top">
<table border="0" width="100%" id="table15" cellspacing="0" cellpadding="0">
<tr>
<td>
<p align="center">帐 号 注 册
<!--img border="0" src="images/zjcx_07_04_01.gif" width="745" height="35"--></td>
</tr>
<tr>
<td>
<table border="0" width="100%" id="table16" cellspacing="0" cellpadding="0">
<tr>
<td width="363">
<img border="0" src="images/zjcx_07_08_01.gif" width="363" height="17"></td>
<td background="images/zjcx_07_08_02.gif">
<img border="0" src="images/zjcx_07_08_02.gif" width="9" height="17"></td>
<td width="373">
<img border="0" src="images/zjcx_07_08_03.gif" width="373" height="17"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table border="0" width="98%" id="table18" cellspacing="0" cellpadding="0">
<tr>
<td>
<form name=reg method=post action="/register.php" onsubmit="return checkpwd(this)">
<table border="0" cellspacing="1" cellpadding="5" bgcolor="#9ad0eb">
<table border="0" cellspacing="1" cellpadding="5" bgcolor="#9ad0eb" width="100%">
<tr bgcolor="#e4f2fa"> <td colspan=3>帐号注册</td></tr>
( * 为必填项)
<tr bgcolor="#e4f2fa">
<td >
<div align="center">用户名<font color="#FF0000">*</font></div>
</td>
<td >
<input type="text" name="username" id="username" size="25" maxlength="15" onBlur="return usercheck('check')">
</td>
<td align="left" bgcolor="#FFFFFF"><!--input type=button value='检查用户名' onclick="return usercheck('check')"--><span id="check"> 3-16个字符,英文小写、汉字、数字、最好不要全部是数字。</span></td> </tr>
<tr bgcolor="#e4f2fa">
<td >
<div align="center">密码<font color="#FF0000">*</font></div>
</td>
<td >
<input type="password" name="password" id="userpwd" onBlur="pwdcheck('pwd')">
</td>
<td align="left" bgcolor="#FFFFFF" id="pwd"> 密码字母有大小写之分。6-16位(包括6、16),限用英文、数字。</td> </tr>
<tr bgcolor="#e4f2fa">
<td >
<div align="center">确认密码<font color="#FF0000">*</font></div>
</td>
<td >
<input type="password" name="checkpassword" id="reuserpwd" onBlur="pwdrecheck('repwd')">
</td>
<td align="left" bgcolor="#FFFFFF" id="repwd"> 请再次输入登录密码。</td>
</tr>
<tr bgcolor="#e4f2fa"><td colspan=3 align="center">
<input type="submit" name=mysubmit value="确定">
<input type=reset value="重填">
</td></tr>
</table>
</form>
<!--文字内容结束--></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" width="100%" id="table17" cellspacing="0" cellpadding="0">
<tr>
<td width="363">
<img border="0" src="images/zjcx_07_08_01.gif" width="363" height="17"></td>
<td background="images/zjcx_07_08_02.gif">
<img border="0" src="images/zjcx_07_08_02.gif" width="9" height="17"></td>
<td width="373">
<img border="0" src="images/zjcx_07_08_03.gif" width="373" height="17"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr><?
require("./include/bottom.inc");
?>
</table>
</div></body></html>
<?
}
$myCxmis->Destroy();
?>
var http_request=false;
function send_request(url){//初始化,指定处理函数,发送请求的函数
http_request=false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest){//Mozilla浏览器
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){//设置MIME类别
http_request.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject){//IE浏览器
try{
http_request=new ActiveXObject("Msxml2.XMLHttp");
}catch(e){
try{
http_request=new ActiveXobject("Microsoft.XMLHttp");
}catch(e){}
}
}
if(!http_request){//异常,创建对象实例失败
window.alert("创建XMLHttp对象失败!");
return false;
}
http_request.onreadystatechange=processrequest;
//确定发送请求方式,URL,及是否同步执行下段代码
http_request.open("GET",url,true);
http_request.send(null);
}
//处理返回信息的函数
function processrequest(){
var mess
if(http_request.readyState==4){//判断对象状态
if(http_request.status==200){//信息已成功返回,开始处理信息
if(http_request.responseText=='exist')
mess="<font color=red>此用户名已经存在,请更换用户名!</font>";
else if(http_request.responseText=='ok')
mess="<font color=red>此用户名可以注册</font>";
else if(http_request.responseText=='right')
mess="<font color=red>旧密码正确</font>";
else if(http_request.responseText=='error')
mess="<font color=red>旧密码不正确</font>";
document.getElementById(reobj).innerHTML=mess;
}
else{//页面不正常
alert("您所请求的页面不正常!");
}
}
}
function usercheck(obj){
var f=document.reg;
var username=f.username.value;
if(username==""){
document.getElementById(obj).innerHTML=" <font color='#ff0000'>用户名不能为空!</font>";
//f.username.focus();
//return false;
}
else if(username.replace(/[^\x00-\xff]/g,'##').length>16){
document.getElementById(obj).innerHTML=" <font color=red>用户名长度不能大于16位(汉字不能超过8个)!</font>";
//f.userpwd.focus();
return false;
}
else{
document.getElementById(obj).innerHTML="正在读取数据...";
send_request('checkuserreg.php?username='+username);
reobj=obj;
}
}
function userpwdcheck(obj){
var f=document.reg;
var oldpassword=f.oldpassword.value;
if(oldpassword==""){
document.getElementById(obj).innerHTML=" <font color='#ff0000'>旧密码不能为空!</font>";
//f.username.focus();
//return false;
}
else{
document.getElementById(obj).innerHTML="正在读取数据...";
send_request('checkuserpwd.php?oldpassword='+oldpassword);
reobj=obj;
}
}
function pwdcheck(obj){
var f=document.reg;
var pwd=f.userpwd.value;
if(pwd==""){
document.getElementById(obj).innerHTML=" <font color=red>用户密码不能为空!</font>";
//f.userpwd.focus();
return false;
}
else if(f.userpwd.value.length<6){
document.getElementById(obj).innerHTML=" <font color=red>密码长度不能小于6位!</font>";
//f.userpwd.focus();
return false;
}
else{
document.getElementById(obj).innerHTML=" <font color=red>密码符合要求!</font>";
}
}
function pwdrecheck(obj){
var f=document.reg;
var repwd=f.reuserpwd.value;
if (repwd==""){
document.getElementById(obj).innerHTML=" <font color=red>请再输入一次密码!</font>";
//f.reuserpwd.focus();
return false;
}
else if(f.userpwd.value!=f.reuserpwd.value){
document.getElementById(obj).innerHTML=" <font color=red>两次输入的密码不一致!</font>";
//f.reuserpwd.focus();
return false;
}
else{
document.getElementById(obj).innerHTML=" <font color=red>密码输入正确!</font>";
}
}
请大家多多发言
这里有一些Ajax入门知识