为什么用这段代码注册会无法显示?

WBOY
Libérer: 2016-06-23 13:38:26
original
1010 Les gens l'ont consulté

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><body><?php$conn=mysql_connect('localhost','root','')or die('数据库连接错误');mysql_select_db('demo',$conn);mysql_query("set names 'gbk'");//检测会员名称是否存在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 "该会员名已经存在!";  }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("注册失败");       echo "<script>alert('注册成功');location.href='login.php'</script>";  }}?><script language="javascript" 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("请输入用户名!");    return false;}if(pwd==""){  alert("请输入密码!");    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'); //获取用于显示结果的span标记 if(name.value.length <= 4){  span.style.color = '#ff0000'; //设置span标记内的字体颜色为红色  span.innerhtml = '用户名长度不能少于4个字符!'; //span标记内容  return false; } var xmlhttp = createxmlhttprequest();//创建异步请求对象 var time = new date().gettime(); var url = 'regval.php?name=' + name.value + '&tmp=' + time;//构造出请求地址 xmlhttp.open("get",url,true); //建立一个异步请求 //这里我们使用get方式请求 xmlhttp.onreadystatechange = function(){ //监视请求状态  span.style.color = '#ff9900';  span.innerhtml = '查询中,请稍候!';  if(xmlhttp.readystate == 4 && xmlhttp.status == 200){alert(xmlhttp.responsetext+"........");   if(xmlhttp.responsetext.indexof('no') != -1){ //如果服务器返回的信息中有no    span.style.color = '#cb2121'; //设置span标记颜色为红色    span.innerhtml = '用户名[' + name.value + ']已经被别的用户使用!';    //document.regform.username.value="";   }else{//如果返回信息中没有no    span.style.color = '#00a800';//设置颜色为绿色    span.innerhtml = '恭喜您,该用户名未被注册!';   }   return true;   delete xmlhttp; //删除请求对象  } } xmlhttp.send(null); //发送请求}</script>  <form action="regval.php" method="post" onsubmit="return docheck()" name="regform">  会员名称:  <input type="text" name="username" value="" id="username" onblur="checkname()"/><span id="name_info"></span>  <br>  密    码:  <input type="password" name="password" value=""/><br>  确认密码:  <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="注册"/>  <input type="reset" name="re" value="取消"/>  </form></body></html>
Copier après la connexion


为什么用这段代码注册会无法显示?

在本地测试的


回复讨论(解决方案)

请对应error.log进行debug.目测的问题$_POST, $_GET,document.getElementById的写法都不对。

请对应error.log进行debug.目测的问题$_POST, $_GET,document.getElementById的写法都不对。


[Tue Mar 10 23:36:43.665381 2015] [mpm_winnt:notice] [pid 10780:tid 488] AH00364: Child: All worker threads have exited.[Tue Mar 10 23:36:43.741430 2015] [mpm_winnt:notice] [pid 19100:tid 552] AH00430: Parent: Child process 10780 exited successfully.[Tue Mar 10 23:36:45.671101 2015] [mpm_winnt:notice] [pid 11236:tid 552] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations[Tue Mar 10 23:36:45.671101 2015] [mpm_winnt:notice] [pid 11236:tid 552] AH00456: Server built: Feb 22 2013 22:08:37[Tue Mar 10 23:36:45.671101 2015] [core:notice] [pid 11236:tid 552] AH00094: Command line: 'e:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d E:/wamp/bin/apache/Apache2.4.4'[Tue Mar 10 23:36:45.673119 2015] [mpm_winnt:notice] [pid 11236:tid 552] AH00418: Parent: Created child process 13684[Tue Mar 10 23:36:46.088542 2015] [mpm_winnt:notice] [pid 13684:tid 476] AH00354: Child: Starting 150 worker threads.[Tue Mar 10 23:36:52.127212 2015] [mpm_winnt:warn] [pid 13684:tid 1740] (OS 64)指定的网络名不再可用。  : AH00341: winnt_accept: Asynchronous AcceptEx failed.[Tue Mar 10 23:36:53.883420 2015] [mpm_winnt:notice] [pid 11236:tid 552] AH00422: Parent: Received shutdown signal -- Shutting down the server.[Tue Mar 10 23:36:55.886829 2015] [mpm_winnt:notice] [pid 13684:tid 476] AH00364: Child: All worker threads have exited.[Tue Mar 10 23:36:55.927857 2015] [mpm_winnt:notice] [pid 11236:tid 552] AH00430: Parent: Child process 13684 exited successfully.[Tue Mar 10 23:36:59.975764 2015] [mpm_winnt:notice] [pid 2240:tid 540] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations[Tue Mar 10 23:36:59.975764 2015] [mpm_winnt:notice] [pid 2240:tid 540] AH00456: Server built: Feb 22 2013 22:08:37[Tue Mar 10 23:36:59.975764 2015] [core:notice] [pid 2240:tid 540] AH00094: Command line: 'e:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d E:/wamp/bin/apache/Apache2.4.4'[Tue Mar 10 23:36:59.978770 2015] [mpm_winnt:notice] [pid 2240:tid 540] AH00418: Parent: Created child process 11228[Tue Mar 10 23:37:00.452720 2015] [mpm_winnt:notice] [pid 11228:tid 312] AH00354: Child: Starting 150 worker threads.[Tue Mar 10 23:37:56.323684 2015] [mpm_winnt:notice] [pid 2240:tid 540] AH00422: Parent: Received shutdown signal -- Shutting down the server.[Tue Mar 10 23:37:58.325482 2015] [mpm_winnt:notice] [pid 11228:tid 312] AH00364: Child: All worker threads have exited.[Tue Mar 10 23:37:58.356504 2015] [mpm_winnt:notice] [pid 2240:tid 540] AH00430: Parent: Child process 11228 exited successfully.[Tue Mar 10 23:38:00.642387 2015] [mpm_winnt:notice] [pid 18584:tid 548] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations[Tue Mar 10 23:38:00.642387 2015] [mpm_winnt:notice] [pid 18584:tid 548] AH00456: Server built: Feb 22 2013 22:08:37[Tue Mar 10 23:38:00.642387 2015] [core:notice] [pid 18584:tid 548] AH00094: Command line: 'e:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d E:/wamp/bin/apache/Apache2.4.4'[Tue Mar 10 23:38:00.644371 2015] [mpm_winnt:notice] [pid 18584:tid 548] AH00418: Parent: Created child process 14260[Tue Mar 10 23:38:01.083798 2015] [mpm_winnt:notice] [pid 14260:tid 480] AH00354: Child: Starting 150 worker threads.[Tue Mar 10 23:38:35.419780 2015] [mpm_winnt:notice] [pid 18584:tid 548] AH00422: Parent: Received shutdown signal -- Shutting down the server.[Tue Mar 10 23:38:37.421735 2015] [mpm_winnt:notice] [pid 14260:tid 480] AH00364: Child: All worker threads have exited.[Tue Mar 10 23:38:37.461744 2015] [mpm_winnt:notice] [pid 18584:tid 548] AH00430: Parent: Child process 14260 exited successfully.[Tue Mar 10 23:38:45.033656 2015] [mpm_winnt:notice] [pid 14176:tid 556] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations[Tue Mar 10 23:38:45.033656 2015] [mpm_winnt:notice] [pid 14176:tid 556] AH00456: Server built: Feb 22 2013 22:08:37[Tue Mar 10 23:38:45.033656 2015] [core:notice] [pid 14176:tid 556] AH00094: Command line: 'e:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d E:/wamp/bin/apache/Apache2.4.4'[Tue Mar 10 23:38:45.035657 2015] [mpm_winnt:notice] [pid 14176:tid 556] AH00418: Parent: Created child process 14404[Tue Mar 10 23:38:45.660099 2015] [mpm_winnt:notice] [pid 14404:tid 292] AH00354: Child: Starting 150 worker threads.[Tue Mar 10 23:38:49.295661 2015] [mpm_winnt:notice] [pid 14176:tid 556] AH00422: Parent: Received shutdown signal -- Shutting down the server.[Tue Mar 10 23:38:51.297859 2015] [mpm_winnt:notice] [pid 14404:tid 292] AH00364: Child: All worker threads have exited.[Tue Mar 10 23:38:51.335879 2015] [mpm_winnt:notice] [pid 14176:tid 556] AH00430: Parent: Child process 14404 exited successfully.[Tue Mar 10 23:38:52.425419 2015] [mpm_winnt:notice] [pid 18756:tid 552] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations[Tue Mar 10 23:38:52.425419 2015] [mpm_winnt:notice] [pid 18756:tid 552] AH00456: Server built: Feb 22 2013 22:08:37[Tue Mar 10 23:38:52.425419 2015] [core:notice] [pid 18756:tid 552] AH00094: Command line: 'e:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d E:/wamp/bin/apache/Apache2.4.4'[Tue Mar 10 23:38:52.427422 2015] [mpm_winnt:notice] [pid 18756:tid 552] AH00418: Parent: Created child process 6948[Tue Mar 10 23:38:53.191963 2015] [mpm_winnt:notice] [pid 6948:tid 476] AH00354: Child: Starting 150 worker threads.[Tue Mar 10 23:39:20.944793 2015] [mpm_winnt:notice] [pid 18756:tid 552] AH00422: Parent: Received shutdown signal -- Shutting down the server.[Tue Mar 10 23:39:22.946980 2015] [mpm_winnt:notice] [pid 6948:tid 476] AH00364: Child: All worker threads have exited.[Tue Mar 10 23:39:23.010024 2015] [mpm_winnt:notice] [pid 18756:tid 552] AH00430: Parent: Child process 6948 exited successfully.[Tue Mar 10 23:39:28.006331 2015] [mpm_winnt:notice] [pid 18600:tid 548] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations[Tue Mar 10 23:39:28.006331 2015] [mpm_winnt:notice] [pid 18600:tid 548] AH00456: Server built: Feb 22 2013 22:08:37[Tue Mar 10 23:39:28.006331 2015] [core:notice] [pid 18600:tid 548] AH00094: Command line: 'e:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d E:/wamp/bin/apache/Apache2.4.4'[Tue Mar 10 23:39:28.007332 2015] [mpm_winnt:notice] [pid 18600:tid 548] AH00418: Parent: Created child process 6216[Tue Mar 10 23:39:28.764743 2015] [mpm_winnt:notice] [pid 6216:tid 512] AH00354: Child: Starting 150 worker threads.[Wed Mar 11 00:09:24.181844 2015] [:error] [pid 6216:tid 1696] [client ::1:50036] script 'E:/wamp/www/regval.php' not found or unable to stat, referer: http://localhost/Untitled-1.html[Wed Mar 11 00:10:31.226423 2015] [mpm_winnt:warn] [pid 6216:tid 2032] (OS 64)指定的网络名不再可用。  : AH00341: winnt_accept: Asynchronous AcceptEx failed.[Wed Mar 11 00:11:03.110783 2015] [mpm_winnt:warn] [pid 6216:tid 2032] (OS 64)指定的网络名不再可用。  : AH00341: winnt_accept: Asynchronous AcceptEx failed.[Wed Mar 11 00:11:03.110783 2015] [mpm_winnt:warn] [pid 6216:tid 2032] (OS 64)指定的网络名不再可用。  : AH00341: winnt_accept: Asynchronous AcceptEx failed.[Wed Mar 11 00:11:03.110783 2015] [mpm_winnt:warn] [pid 6216:tid 2032] (OS 64)指定的网络名不再可用。  : AH00341: winnt_accept: Asynchronous AcceptEx failed.[Wed Mar 11 00:11:33.322364 2015] [:error] [pid 6216:tid 1696] [client ::1:50054] script 'E:/wamp/www/regval.php' not found or unable to stat, referer: http://localhost/Untitled-1.html[Wed Mar 11 14:44:42.937772 2015] [:error] [pid 6216:tid 1696] [client ::1:33996] script 'E:/wamp/www/regval.php' not found or unable to stat, referer: http://localhost/Untitled-1.html
Copier après la connexion

2015-03-10 23:38:46 18496 [Note] InnoDB: Waiting for purge to start2015-03-10 23:38:46 18496 [Note] InnoDB: 5.6.12 started; log sequence number 16260272015-03-10 23:38:46 18496 [Note] Server hostname (bind-address): '*'; port: 33062015-03-10 23:38:46 18496 [Note] IPv6 is available.2015-03-10 23:38:46 18496 [Note]   - '::' resolves to '::';2015-03-10 23:38:46 18496 [Note] Server socket created on IP: '::'.2015-03-10 23:38:46 18496 [Note] Event Scheduler: Loaded 0 events2015-03-10 23:38:46 18496 [Note] wampmysqld: ready for connections.Version: '5.6.12-log'  socket: ''  port: 3306  MySQL Community Server (GPL)2015-03-10 23:59:53 18496 [Note] wampmysqld: Normal shutdown2015-03-10 23:59:53 18496 [Note] Giving 0 client threads a chance to die gracefully2015-03-10 23:59:53 18496 [Note] Event Scheduler: Purging the queue. 0 events2015-03-10 23:59:53 18496 [Note] Shutting down slave threads2015-03-10 23:59:53 18496 [Note] Forcefully disconnecting 0 remaining clients2015-03-10 23:59:53 18496 [Note] Binlog end2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'partition'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_SYS_TABLES'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_FT_CONFIG'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_FT_DELETED'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_METRICS'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_CMPMEM'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_CMP_RESET'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_CMP'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_LOCKS'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'INNODB_TRX'2015-03-10 23:59:53 18496 [Note] Shutting down plugin 'InnoDB'2015-03-10 23:59:53 18496 [Note] InnoDB: FTS optimize thread exiting.2015-03-10 23:59:53 18496 [Note] InnoDB: Starting shutdown...2015-03-10 23:59:54 18496 [Note] InnoDB: Shutdown completed; log sequence number 16260372015-03-10 23:59:54 18496 [Note] Shutting down plugin 'BLACKHOLE'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'ARCHIVE'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'MRG_MYISAM'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'MyISAM'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'MEMORY'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'CSV'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'sha256_password'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'mysql_old_password'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'mysql_native_password'2015-03-10 23:59:54 18496 [Note] Shutting down plugin 'binlog'2015-03-10 23:59:54 18496 [Note] wampmysqld: Shutdown complete2015-03-10 23:59:59 19492 [Note] Plugin 'FEDERATED' is disabled.2015-03-10 23:59:59 19492 [Note] InnoDB: The InnoDB memory heap is disabled2015-03-10 23:59:59 19492 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions2015-03-10 23:59:59 19492 [Note] InnoDB: Compressed tables use zlib 1.2.32015-03-10 23:59:59 19492 [Note] InnoDB: Not using CPU crc32 instructions2015-03-10 23:59:59 19492 [Note] InnoDB: Initializing buffer pool, size = 128.0M2015-03-10 23:59:59 19492 [Note] InnoDB: Completed initialization of buffer pool2015-03-10 23:59:59 19492 [Note] InnoDB: Highest supported file format is Barracuda.2015-03-11 00:00:04 19492 [Note] InnoDB: 128 rollback segment(s) are active.2015-03-11 00:00:04 19492 [Note] InnoDB: Waiting for purge to start2015-03-11 00:00:04 19492 [Note] InnoDB: 5.6.12 started; log sequence number 16260372015-03-11 00:00:04 19492 [Note] Server hostname (bind-address): '*'; port: 33062015-03-11 00:00:04 19492 [Note] IPv6 is available.2015-03-11 00:00:04 19492 [Note]   - '::' resolves to '::';2015-03-11 00:00:04 19492 [Note] Server socket created on IP: '::'.2015-03-11 00:00:05 19492 [Note] Event Scheduler: Loaded 0 events2015-03-11 00:00:05 19492 [Note] wampmysqld: ready for connections.Version: '5.6.12-log'  socket: ''  port: 3306  MySQL Community Server (GPL)
Copier après la connexion

还是看看服务端吧 !  是不是数据库没连上,看看数据库用户名和密码对不对!

大哥啊,你把几个页面的代码挤到一起要干嘛啊

source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!