无法注册,不能弹出注册成功的窗口,数据库没有增加新用户,
register.php
<table border="0" align="center" cellpadding="0" cellspacing="0"> <tr><td><p>注册名称:</p></td><td><input id="regname" name="regname" type="text" class="txt" /></td><td><div id="namediv" class="regdiv"> 名称由字母及下划线组成</div></td></tr> <tr><td><p>注册密码:</p></td><td><input id="regpwd1" name="regpwd1" type="password" class="txt" /></td><td><div id="pwddiv1" class="regdiv"> 请输入密码</div></td></tr> <tr><td><p>确认密码:</td><td><input id="regpwd2" name="regpwd2" type="password" class="txt" /></td><td><div id="pwddiv2" class="regdiv"> 确认密码</div></td></tr> <tr><td colspan="3"><a id="morebtn">更多.......</a><input id="chknm" name="chknm" type="hidden" value="" /></td></tr> </table> <div id="morediv" style="display:none;padding:0 0 0 57px;"> <hr /> <table border="0" cellpadding="0" cellspacing="0" id="regfm"> <tr><td style="width:70px;">密保问题:</td><td><input id="question" name="question" type="text" /></td></tr> <tr><td>密保答案:</td><td><input id="answer" name="answer" type="text" /></td></tr> <tr><td>电子邮件:</td><td><input type="text" name="xuehao" id="xuehao" /></td></tr> <tr><td>QQ号码:</td><td><input type="text" name="xuehao" id="xuehao" /></td></tr> <tr><td>手机号码:</td><td><input type="text" name="xuehao" id="xuehao" /></td></tr> <tr><td>真实姓名:</td><td><input type="text" name="relname" id="relname" /></td></tr> <tr><td>河海学号:</td><td><input type="text" name="xuehao" id="xuehao" /></td></tr> <tr><td style="height:40px;">性别:</td><td> <select id="sex" name="sex"> <option value='男' selected="selected">男</option> <option value='女'>女</option> </select></td></tr> <tr><td style="height:40px;">出生日期:</td><td> <select id='year' name='year' style="width:70px;"> <option value="<?php echo date('Y'); ?>" selected="selected"><?php echo date('Y'); ?></option> <?php for($i=1900;$i<2024;$i++){ ?> <option value="<?php echo $i; ?>"><?php echo $i; ?></option> <?php } ?> </select> 年 <select id="month" name="month"> <?php for($i=1;$i<=12;$i++){ ?> <option value="<?php echo $i; ?>"><?php echo $i; ?></option> <?php } ?> </select> 月 <select id="day" name="day"> <?php for($i=1;$i<=31;$i++){ ?> <option value="<?php echo $i; ?>"><?php echo $i; ?></option> <?php } ?> </select> 日 </td></tr> </table>
register.js
// JavaScript Documentfunction $(id){ return document.getElementById(id);}window.onload = function(){ $('regname').focus(); var cname1,cname2,cpwd1,cpwd2; //验证用户名 $('regname').onkeyup = function (){ name = $('regname').value; cname2 = ''; if(name.match(/^[a-zA-Z_]*/) == ''){ $('namediv').innerHTML = '<font color=red>必须以字母和下划线开头</font>'; cname1 = ''; }else if(name.length <= 3){ $('namediv').innerHTML = '<font color=red>注册名称必须大于三位</font>'; cname1 = ''; }else{ $('namediv').innerHTML = '<font color=green>注册名称符合标准</font>'; 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'){ $('namediv').innerHTML="<font color=green>用户名可以使用!</font>"; cname2 = 'yes'; }else if(msg == '2'){ $('namediv').innerHTML="<font color=red>用户名被占用!</font>"; cname2 = ''; }else{ $('namediv').innerHTML="<font color=red>"+msg+"</font>"; cname2 = ''; } } } } xmlhttp.send(null); chkreg(); } } $('regpwd1').onkeyup = function(){ pwd = $('regpwd1').value; pwd2 = $('regpwd2').value; if(pwd.length < 6){ $('pwddiv1').innerHTML = '<font color=red>密码最少需6位!</font>'; cpwd1 = ''; }else if(pwd.length >= 6 && pwd.length < 12){ $('pwddiv1').innerHTML = '<font color=green>密码符合要求。密码强度:弱</font>'; cpwd1 = 'yes'; }else if((pwd.match(/^[0-9]*$/)!=null) || (pwd.match(/^[a-zA-Z]*$/) != null )){ $('pwddiv1').innerHTML = '<font color=green>密码符合要求。密码强度:中</font>'; cpwd1 = 'yes'; }else{ $('pwddiv1').innerHTML = '<font color=green>密码符合要求。密码强度:强</font>'; cpwd1 = 'yes'; } if(pwd2 != '' && pwd != pwd2){ $('pwddiv2').innerHTML = '<font color=red>两次密码不一致</font>'; cpwd2 = ''; }else if(pwd2 != '' && pwd == pwd2){ $('pwddiv2').innerHTML = '<font color=green>密码输入正确</font>'; cpwd2 = 'yes'; } chkreg(); } $('regpwd2').onkeyup = function(){ pwd1 = $('regpwd1').value; pwd2 = $('regpwd2').value; if(pwd1 != pwd2){ $('pwddiv2').innerHTML = '<font color=red>两次密码不一致!</font>'; cpwd2 = ''; }else{ $('pwddiv2').innerHTML = '<font color=green>密码输入正确!</font>'; 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($('morediv').style.display == ''){ $('morediv').style.display = 'none'; }else{ $('morediv').style.display = ''; } } //正式注册 $('regbtn').onclick = function(){ name = $('regname').value; pwd = $('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(); alert('注册成功!'); location='yhzx.php'; }else{ alert(msg); } } } } xmlhttp.send(null); }}
register_chk.php
<?php session_start(); header('Content-Type:text/html;charset=utf-8'); include_once 'conn/conn.php'; include_once '../config.php'; $reback = '0'; //echo $_GET['headgif']; $sql = "insert into tb_users(name,pwd,question,answer,realname,xuehao,sex,tel,email,qq,birthday) values('".trim($_GET['name'])."','".md5(trim($_GET['pwd']))."','".$_GET['question']."','".$_GET['answer']."','".$_GET['realname']."','".$_GET['xuehao']."','".$_GET['sex']."','".$_GET['tel']."','".$_GET['email']."','".$_GET['qq']."','".$_GET['birthday'].'")"; $num = $conne->uidRst($sql); if($num == 1){ $_SESSION['name'] = $_GET['name']; $reback = '1'; }else{ $reback = $conne->msg_error(); } echo $reback;?>
chk_name.php
<?phpsession_start();include_once "conn/conn.php";$reback = '0';$sql = "select * from tb_member where name='".$_GET['name']."'";$num = $conne->getRowsNum($sql);if($num == 1){ $reback = '2';}else if($num == 0){ $reback = '1';}else{ $reback = $conne->msg_error();}echo $reback;?>
回复讨论(解决方案)
代码太多,先告诉我们 提交上去的数据是否正确 返回结果又是什么?
你真实够可以的,连代码都不给全,怎么帮你查错?
我靠,js啊
我是来学习的
解决问题自己不急 你当比人来给你急啊 代码都不全 我擦
你可以直接抛开 ajax 先用php注册看能不能成功 在看下js发的数据是不是完整和对的
找不出毛病,就怪我代码没给全,我才擦呢,再也不来了,一堆没耐心的家伙,态度越来越差了,什么东西都没解答出来吃干饭,恶心死了。

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

PHPisusedforsendingemailsduetoitsbuilt-inmail()functionandsupportivelibrarieslikePHPMailerandSwiftMailer.1)Usethemail()functionforbasicemails,butithaslimitations.2)EmployPHPMailerforadvancedfeatureslikeHTMLemailsandattachments.3)Improvedeliverability

PHP performance bottlenecks can be solved through the following steps: 1) Use Xdebug or Blackfire for performance analysis to find out the problem; 2) Optimize database queries and use caches, such as APCu; 3) Use efficient functions such as array_filter to optimize array operations; 4) Configure OPcache for bytecode cache; 5) Optimize the front-end, such as reducing HTTP requests and optimizing pictures; 6) Continuously monitor and optimize performance. Through these methods, the performance of PHP applications can be significantly improved.

DependencyInjection(DI)inPHPisadesignpatternthatmanagesandreducesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itallowspassingdependencieslikedatabaseconnectionstoclassesasparameters,facilitatingeasiertestingandscalability.

CachingimprovesPHPperformancebystoringresultsofcomputationsorqueriesforquickretrieval,reducingserverloadandenhancingresponsetimes.Effectivestrategiesinclude:1)Opcodecaching,whichstorescompiledPHPscriptsinmemorytoskipcompilation;2)DatacachingusingMemc


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
