国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php 用戶注冊頁面代碼

2024-05-04 23:06:13
字體:
來源:轉載
供稿:網友

php 用戶注冊頁面代碼 這款用戶注冊程序是一款包括有數據庫,注冊頁面,注冊js 驗證是一款完整理的php+mysql實用的用戶注冊代碼。

  1. */ 
  2. $conn=mysql_connect('localhost','root','root')or die('數據庫連接錯誤'); 
  3. mysql_select_db('demo',$conn); 
  4. mysql_query("set names 'gbk'"); 
  5. //檢測會員名稱是否存在 
  6. if($_post[username]){ 
  7.   $sql="select * from users where username='$_post[username]'"
  8.   $res=mysql_query($sql)or die("查詢失??!"); 
  9.   $us=$_get[name]; 
  10.   echo $us."222222"
  11.   $ps= md5($_post[password]); 
  12.   $sex=$_post['sex']; 
  13.   $age=$_post['age']; 
  14.   $qq=$_post['qq']; 
  15.   $phone=$_post['phone']; 
  16.   $email=$_post['email']; 
  17.   $address=$_post['address']; 
  18.   if(is_array(mysql_fetch_row($res))){ 
  19.        echo "該會員名已經存在!"
  20.   }else
  21.         $sql="insert into users (username,password,sex,age,qq,phone,email,address) values ('$us','$ps',$sex,$age,$qq,'$phone','$email','$address')"
  22.         echo $sql
  23.        mysql_query($sql)or die("注冊失敗"); 
  24.        echo "<script>alert('注冊成功');location.href='login.php'</script>"
  25.   } 
  26. ?> 
  27. <script language="" type="text/javascript"
  28. function docheck(){ 
  29. var username = document.regform.username.value; 
  30. var pwd =document.regform.password.value; 
  31. var repwd=document.regform.repassword.value; 
  32. if(username==""){ 
  33.   alert("請輸入用戶名!"); 
  34.     return false; 
  35. if(pwd==""){ 
  36.   alert("請輸入密碼!"); 
  37.     return false; 
  38. if(repwd != pwd){ 
  39.   alert("兩次填寫的密碼不相同!"); 
  40.   return false; 
  41. </script> 
  42. <script language="javascript"
  43. function createxmlhttprequest(){ 
  44.  var xmlhttp; 
  45.  if(window.activexobject){ 
  46.   xmlhttp = new activexobject("microsoft.xmlhttp"); 
  47.  }else
  48.   xmlhttp = new xmlhttprequest(); 
  49.  } 
  50.  //return xmlhttp; 
  51. function checkname(){ 
  52.  var name = document.getelementbyid('username'); //獲取用戶名文本框 
  53.  var span = document.getelementbyid('name_info'); //獲取用于顯示結果的span標記 
  54.  if(name.value.length <= 4){ 
  55.   span.style.color = '#ff0000'//設置span標記內的字體顏色為紅色 
  56.   span.innerhtml = '用戶名長度不能少于4個字符!'//span標記內容 
  57.   return false; 
  58.  } 
  59.  var xmlhttp = createxmlhttprequest();//創建異步請求對象 
  60.  var time = new date().gettime(); 
  61.  var url = 'regval.php?name=' + name.value + '&tmp=' + time;//構造出請求地址 
  62.  xmlhttp.open("get",url,true); //建立一個異步請求 
  63.  //這里我們使用get方式請求 
  64.  xmlhttp.onreadystatechange = function(){ //監視請求狀態 
  65.   span.style.color = '#ff9900'
  66.   span.innerhtml = '查詢中,請稍候!'
  67.   if(xmlhttp.readystate == 4 && xmlhttp.status == 200){ 
  68. alert(xmlhttp.responsetext+"........"); 
  69.    if(xmlhttp.responsetext.indexof('no') != -1){ //如果服務器返回的信息中有no 
  70.     span.style.color = '#cb2121'//設置span標記顏色為紅色 
  71.     span.innerhtml = '用戶名[' + name.value + ']已經被別的用戶使用!'
  72.     //document.regform.username.value=""; 
  73.    }else{//如果返回信息中沒有no 
  74.     span.style.color = '#00a800';//設置顏色為綠色 
  75.     span.innerhtml = '恭喜您,該用戶名未被注冊!'
  76.    } 
  77.    return true; 
  78.    delete xmlhttp; //刪除請求對象 
  79.   } 
  80.  } 
  81.  xmlhttp.send(null); //發送請求 
  82. </script> 
  83.   <form action="regval.php" method="post" onsubmit="return docheck()" name="regform"
  84.   會員名稱: 
  85.   <input type="text" name="username" value="" id="username" onblur="checkname()"/> 
  86. <span id="name_info"></span> 
  87.   <br> 
  88.   密&nbsp;&nbsp;&nbsp;&nbsp;碼: 
  89.   <input type="password" name="password" value=""/><br> 
  90.   確認密碼: 
  91.   <input type="password" name="repassword" value=""/><br> 
  92. 性別: 
  93. 男:<input name="sex" type="radio" value="0" checked="checked"/> 
  94. 女:<input name="sex" type="radio" value="1"/><br> 
  95. 年齡:<input type="text" name="age" value=""/><br> 
  96. qq:<input type="text" name="qq" value=""/><br> 
  97. 電話:<input type="text" name="phone" value=""/><br> 
  98. email:<input type="text" name="email" value=""/><br> 
  99. 地址:<input type="text" name="address" value=""/><br> 
  100.   <input type="submit" name="sub" value="注冊"/> 
  101.   <input type="reset" name="re" value="取消"/> 
  102.   </form> 
  103. <? 
  104. /* 
  105. drop table if exists `users`; 
  106. create table `users` ( 
  107.   `id` int(10) not null auto_increment, 
  108.   `username` varchar(50) not null, 
  109.   `password` varchar(50) not null, 
  110.   `sex` int(1) not null default '0'
  111.   `age` int(10) not null, 
  112.   `qq` int(15) default null, 
  113.   `phone` varchar(50) default null, 
  114.   `email` varchar(50) default null, 
  115.   `address` varchar(100) default null, 
  116.   primary key (`id`) 
  117. ) engine=innodb auto_increment=4 default charset=gbk; 
  118. -- ---------------------------- 
  119. -- records of users 
  120. -- ---------------------------- 
  121. insert into `users` values ('1''admin''21232f297a57a5a743894a0e4a801fc3''0''22''379559090''666666''666666@163.com''武漢'); 
  122. insert into `users` values ('2''root''63a9f0ea7bb98050796b649e85481845''0''20''1244249796''8888888''8888888@163.com''中國'); 
  123. insert into `users` values ('3''www.111cn.net''96e79218965eb72c92a549dd5a330112''0''20''1244249796''8888888''8888888@163.com''中國'); 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 美姑县| 麟游县| 新密市| 博兴县| 长葛市| 桑植县| 东城区| 永兴县| 白玉县| 安庆市| 牡丹江市| 逊克县| 建平县| 拉孜县| 鱼台县| 万荣县| 高雄县| 桐柏县| 闻喜县| 河东区| 丽水市| 白河县| 凌海市| 大新县| 略阳县| 太湖县| 龙岩市| 奈曼旗| 乌拉特后旗| 治县。| 阳山县| 龙海市| 东乌珠穆沁旗| 巴东县| 大理市| 青州市| 元谋县| 昌邑市| 洪泽县| 赤水市| 仪征市|