文本《PHP用戶注冊(cè)程序教程+用戶注冊(cè)頁(yè)面代碼》介紹的程序是一款用戶注冊(cè)程序,它是一款包括有數(shù)據(jù)庫(kù)教程,注冊(cè)頁(yè)面,注冊(cè)網(wǎng)頁(yè)特效 驗(yàn)證是一款完整理的php+mysql教程實(shí)用的用戶注冊(cè)代碼。
*/
$conn=mysql_connect('localhost','root','root')or die('數(shù)據(jù)庫(kù)連接錯(cuò)誤');
mysql_select_db('demo',$conn);
mysql_query("set names 'gbk'");
//檢測(cè)會(huì)員名稱是否存在
if($_post[username]){
$sql="select * from users where username='$_post[username]'";
$res=mysql_query($sql)or die("查詢失敗!");
$us=$_get[name];
echo $us."222222";
$ps= md5($_post[password]);
$sex=$_post['sex'];
$age=$_post['age'];
$qq=$_post['qq'];
$phone=$_post['phone'];
$email=$_post['email'];
$address=$_post['address'];
if(is_array(mysql_fetch_row($res))){
echo "該會(huì)員名已經(jīng)存在!";
}else{
$sql="insert into users (username,password,sex,age,qq,phone,email,address) values ('$us','$ps',$sex,$age,$qq,'$phone','$email','$address')";
echo $sql;
mysql_query($sql)or die("注冊(cè)失敗");
echo "<script>alert('注冊(cè)成功');location.href='login.php'</script>";
}
}
?>
<script language="網(wǎng)頁(yè)特效" type="text/javascript">
function docheck(){
var username = document.regform.username.value;
var pwd =document.regform.password.value;
var repwd=document.regform.repassword.value;
if(username==""){
alert("請(qǐng)輸入用戶名!");
return false;
}
if(pwd==""){
alert("請(qǐng)輸入密碼!");
return false;
}
if(repwd != pwd){
alert("兩次填寫的密碼不相同!");
return false;
}
}
</script>
<script language="javascript">
function createxmlhttprequest(){
var xmlhttp;
if(window.activexobject){
xmlhttp = new activexobject("microsoft.xmlhttp");
}else{
xmlhttp = new xmlhttprequest();
}
//return xmlhttp;
}
function checkname(){
var name = document.getelementbyid('username'); //獲取用戶名文本框
var span = document.getelementbyid('name_info'); //獲取用于顯示結(jié)果的span標(biāo)記
if(name.value.length <= 4){
span.style.color = '#ff0000'; //設(shè)置span標(biāo)記內(nèi)的字體顏色為紅色
span.innerhtml = '用戶名長(zhǎng)度不能少于4個(gè)字符!'; //span標(biāo)記內(nèi)容
return false;
}
var xmlhttp = createxmlhttprequest();//創(chuàng)建異步請(qǐng)求對(duì)象
var time = new date().gettime();
var url = 'regval.php?name=' + name.value + '&tmp=' + time;//構(gòu)造出請(qǐng)求地址
xmlhttp.open("get",url,true); //建立一個(gè)異步請(qǐng)求
//這里我們使用get方式請(qǐng)求
xmlhttp.onreadystatechange = function(){ //監(jiān)視請(qǐng)求狀態(tài)
span.style.color = '#ff9900';
span.innerhtml = '查詢中,請(qǐng)稍候!';
if(xmlhttp.readystate == 4 && xmlhttp.status == 200){
alert(xmlhttp.responsetext+"........");
if(xmlhttp.responsetext.indexof('no') != -1){ //如果服務(wù)器返回的信息中有no
span.style.color = '#cb2121'; //設(shè)置span標(biāo)記顏色為紅色
span.innerhtml = '用戶名[' + name.value + ']已經(jīng)被別的用戶使用!';
//document.regform.username.value="";
}else{//如果返回信息中沒(méi)有no
span.style.color = '#00a800';//設(shè)置顏色為綠色
span.innerhtml = '恭喜您,該用戶名未被注冊(cè)!';
}
return true;
delete xmlhttp; //刪除請(qǐng)求對(duì)象
}
}
xmlhttp.send(null); //發(fā)送請(qǐng)求
}
</script>
<form action="regval.php" method="post" onsubmit="return docheck()" name="regform">
會(huì)員名稱:
<input type="text" name="username" value="" id="username" onblur="checkname()"/>
<span id="name_info"></span>
<br>
密 碼:
<input type="password" name="password" value=""/><br>
確認(rèn)密碼:
<input type="password" name="repassword" value=""/><br>
性別:
男:<input name="sex" type="radio" value="0" checked="checked"/>
女:<input name="sex" type="radio" value="1"/><br>
年齡:<input type="text" name="age" value=""/><br>
qq:<input type="text" name="qq" value=""/><br>
電話:<input type="text" name="phone" value=""/><br>
email:<input type="text" name="email" value=""/><br>
地址:<input type="text" name="address" value=""/><br>
<input type="submit" name="sub" value="注冊(cè)"/>
<input type="reset" name="re" value="取消"/>
</form>
<?
/*《PHP用戶注冊(cè)程序教程+用戶注冊(cè)頁(yè)面代碼》
drop table if exists `users`;
create table `users` (
`id` int(10) not null auto_increment,
`username` varchar(50) not null,
`password` varchar(50) not null,
`sex` int(1) not null default '0',
`age` int(10) not null,
`qq` int(15) default null,
`phone` varchar(50) default null,
`email` varchar(50) default null,
`address` varchar(100) default null,
primary key (`id`)
) engine=innodb auto_increment=4 default charset=gbk;
-- ----------------------------
-- records of users
-- ----------------------------
insert into `users` values ('1', 'admin', '21232f297a57a5a743894a0e4a801fc3', '0', '22', '379559090', '666666',
insert into `users` values ('2', 'root', '63a9f0ea7bb98050796b649e85481845', '0', '20', '1244249796', '8888888', insert into `users` values ('3', 'www.111cn.net', '96e79218965eb72c92a549dd5a330112', '0', '20', '1244249796', '8888888',
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。