PhpAjax cannot log on and cannot be registered. the registration successful window is not displayed, and no new users are added to the database,
Register. php
Registration name: |
|
The name consists of letters and underscores |
Registration password: |
|
Enter password |
Confirm password: |
|
Confirm password |
| More ....... |
| Security questions: |
|
| Password protection answer: |
|
| Email: |
|
| QQ number: |
|
| Mobile phone number: |
|
| Real name: |
|
| River sea student ID: |
|
| Gender: |
MaleFemale |
| Date of birth: |
Year
Month
Day |
Register. js
// JavaScript Documentfunction $ (id) {return document. getElementById (id);} window. onload = function () {$ ('regname '). focus (); var cname1, cname2, cpwd1, cpwd2; // verify the username $ ('regname '). onkeyup = function () {name = $ ('regname '). value; cname2 = ''; if (name. match (/^ [a-zA-Z _] */) = '') {$ ('namep '). innerHTML = 'must start with a letter or underscore'; cname1 = '';} else if (name. length <= 3) {$ ('namep '). innerHTML = 'registration name must be greater than three status'; cname1 = '';} else {$ ('n Amep '). innerHTML = 'registration name complies with the standard'; cname1 = 'yes';} chkreg () ;}$ ('regname '). onblur = function () {name = $ ('regname '). value; if (cname1 = 'yes') {xmlhttp. open ('GET', 'chkname. php? Name = '+ name, true); xmlhttp. onreadystatechange = function () {if (xmlhttp. readyState = 4) {if (xmlhttp. status = 200) {var msg = xmlhttp. responseText; if (msg = '1') {$ ('namep '). innerHTML = "the user name can be used! "; Cname2 = 'yes';} else if (msg = '2') {$ ('namep '). innerHTML =" the user name is occupied! "; Cname2 ='';} else {$ ('namep '). innerHTML = "" + msg + ""; cname2 = '';}}} xmlhttp. send (null); chkreg () ;}$ ('regpwd1 '). onkeyup = function () {pwd = $('regpwd1 '). value; pwd2 = $('regpwd2 '). value; if (pwd. length <6) {$ ('pwdp1 '). innerHTML = 'the password must contain at least 6 characters! '; Cpwd1 = '';} else if (pwd. length> = 6 & pwd. length <12) {$ ('pwdp1'). innerHTML =' The password meets the requirements. Password strength: weak '; cpwd1 = 'yes';} else if (pwd. match (/^ [0-9] * $ /)! = Null) | (pwd. match (/^ [a-zA-Z] * $ /)! = Null) {$ ('pwdp1'). innerHTML = 'The password meets the requirements. Password strength: Medium '; cpwd1 = 'yes';} else {$ ('pwdp1'). innerHTML =' The password meets the requirements. Password strength: Strong '; cpwd1 = 'yes';} if (pwd2! = ''& Pwd! = Pwd2) {$ ('pwdp2'). innerHTML = 'inconsistent two passwords '; cpwd2 = '';} else if (pwd2! = ''& Pwd = pwd2) {$ ('pwdp2 '). innerHTML = 'password entered correctly '; cpwd2 = 'yes';} chkreg () ;}$ ('regpwd2 '). onkeyup = function () {pwd1 = $('regpwd1 '). value; pwd2 = $('regpwd2 '). value; if (pwd1! = Pwd2) {$ ('pwdp2'). innerHTML = 'inconsistent passwords! '; Cpwd2 = '';} else {$ ('pwdp2'). innerHTML = 'The password is entered correctly! '; Cpwd2 = 'yes';} chkreg ();} function chkreg () {if (cname1 = 'yes') & (cname2 = 'yes ') & (cpwd1 = 'yes') & (cpwd2 = 'yes') {$ ('regbtn '). disabled = false;} else {$ ('regbtn '). disabled = true ;}$ ('morebtn '). onclick = function () {if ($ ('morep '). style. display = '') {$ ('morep '). style. display = 'none';} else {$ ('morep '). style. display = '';}// officially registered $ ('regbtn '). onclick = function () {name = $ ('regname '). value; pw D = $('regpwd1 '). value; question1 = $ ('question '). value; answer1 = $ ('answer '). value; realname1 = $ ('realname '). value; xuehao1 = $ ('xuehao '). value; email1 = $ ('email '). value; qq1 = $ ('QQ '). value; tel1 = $ ('tel '). value; sex1 = $ ('sex '). value; birthday1 = $ ('year '). value + '-' + $ ('month '). value + '-' + $ ('day '). value; url = 'register _ chk. php? Name = '+ name +' & pwd = '+ pwd; url + = '& question =' + question1 + '& answer =' + answer1 + '& email =' + email1; url + = '& qq =' + qq1 + '& tel =' + tel1; url + = '& realname =' + realname1 + '& xuehao =' + xuehao1 + '& sex =' + sex1 + '& birthday =' + birthday1; xmlhttp. open ('GET', url, true); xmlhttp. onreadystatechange = function () {if (xmlhttp. readyState = 4) {if (xmlhttp. status = 200) {msg = xmlhttp. responseText; if (msg = '1') {top. opener. location. reload (); Lert ('registration successful! '); Location = 'yhzx. php';} else {alert (msg) ;}}} xmlhttp. send (null );}}
Register_chk.php
uidRst($sql);if($num == 1){$_SESSION['name'] = $_GET['name'];$reback = '1';}else{$reback = $conne->msg_error();}echo $reback;?>
Chk_name.php
getRowsNum($sql);if($num == 1){$reback = '2';}else if($num == 0){$reback = '1';}else{$reback = $conne->msg_error();}echo $reback;?>
Reply to discussion (solution)
There are too many codes. tell us whether the submitted data is correct and what is the returned result?
You really can do it, and even the code is not complete. how can I help you find the error?
I rely on js.
I am here to learn
Don't worry about solving the problem. you should be more anxious than anyone else. I will clean all the code.
You can directly register ajax with php to check whether the data sent by js is complete and correct.
If I can't find anything wrong, I blame my code for not giving it all. I just wiped it and never again. a bunch of impatient guys are getting worse and worse, and I have not answered anything for a dry meal, disgusting.