ホームページ >バックエンド開発 >PHPチュートリアル >QQ の入力を追加しましたが、送信されたデータは保存されません。何が起こっていますか?
推奨される登録ファイルにはユーザー名とパスワードのみを入力できます。QQ に入力するために別のユーザー名を追加したいのですが、QQ がテーブルに保存されません。
バックグラウンドでユーザーを追加する機能があります。 QQ を入力する機能があり、バックグラウンドで入力した QQ をデータベースに保存できます。
プロモーションリンクファイルコード:
<form action="/index.php/user/registered" method="post" onajax="registerBeforSubmit" enter="true" call="registerSubmit" target="ajax"> <input type="hidden" name="parentId" value="<?=$args[0]?>" /> <div class="tr"><span style="width:65px; overflow:hidden; white-space:nowrap;">用户名</span><input class="inp-1 img-login" name="username" /></div> <div class="tr"><span style="width:65px; overflow:hidden; white-space:nowrap;">密 码</span><input class="inp-1 img-login" name="password" type="password" /></div> <div class="tr"><span style="width:65px; overflow:hidden; white-space:nowrap;">确认密码</span><input id="cpasswd" type="password" class="inp-1 img-login" /></div> <div class="tr"><span style="width:65px; overflow:hidden; white-space:nowrap;">联系QQ</span><input name="qq" class="inp-1 img-login" value="" /></div> <div class="tr"><span style="width:65px; overflow:hidden; white-space:nowrap;">验证码</span><span class="yzmNum"><img width="72" height="24" border="0" style="margin:0;" align="absmiddle" src="/index.php/user/vcode/<?=$this->time?>" title="看不清楚嘛,点击切换一张图片吧" onclick="this.src='/index.php/user/vcode/'+(new Date()).getTime()"/></span><input class="inp-2 img-login" name="vcode" /></div> <div style="display:none;"><input type="submit" value=""/></div> <div class="login-btn-reg img-login" onclick="$(this).closest('form').submit()"></div> </form>
//{{{推广注册function registerBeforSubmit(){ var type=$('[name=type]:checked',this).val(); //console.log($('[name=type]:checked',this)); if(!this.username.value) throw('没有输入用户名'); if(!/^\w{4,16}$/.test(this.username.value)) throw('用户名由4到16位的字母、数字及下划线组成'); if(!this.password.value) throw('请输入密码'); if(this.password.value.length<6) throw('密码至少6位'); if(document.getElementById('cpasswd').value!=this.password.value) throw('两次输入密码不一样'); if(!this.qq.value) throw('没有输入联系QQ');}function registerSubmit(err,data){ if(err){ alert(err); }else{ location='/'; }}//}}}
<form action="/admin.php/member/added" method="post" target="ajax" onajax="beforeAddMember" call="addMember"> <table class="tablesorter table2" cellspacing="0" width="100%"> <tr> <td><span class="aq-txt">账号类型:</span></td> <td> <label><input name="type" type="radio" value="1" title="代理" checked="checked" />代理</label> <label><input name="type" type="radio" value="0" title="会员" style="margin-left:30px;" />会员</label> </td> </tr> <tr> <td><span class="aq-txt">用户名:</span></td> <td><input type="text" name="username" class="t-c" value="" /></td> </tr> <tr> <td><span class="aq-txt">密码:</span></td> <td><input name="password" type="password" class="t-c" value="" /></td> </tr> <tr> <td><span class="aq-txt">确认密码:</span></td> <td><input id="cpasswd" type="password" class="t-c" value="" /></td> </tr> <tr> <td><span class="aq-txt">联系 Q Q:</span></td> <td><input name="qq" class="inp-1 img-login" value="" /></td> </tr> <tr> <td></td> <td><input type="submit" class="alt_btn" value="增加成员"/></td> </tr> </table> </form>
/** * 推广注册 */ public final function register($userxxx){ if(!$userxxx){ //throw new Exception('链接错误!'); $this->display('team/register.php'); }else{ include_once $_SERVER['DOCUMENT_ROOT'].'/lib/classes/Xxtea.class'; $userxxx=str_replace(array('-','*',''), array('+','/','='), $userxxx); $userxxx=base64_decode($userxxx); $uid=Xxtea::decrypt($userxxx, $this->urlPasswordKey); if(!$this->getRow("select uid from {$this->prename}members where uid=?",$uid)){ //throw new Exception('链接失效!'); $this->display('team/register.php'); }else{ $this->display('team/register.php',0,$uid); } } } public final function registered(){ if(strtolower($_POST['vcode'])!=$_SESSION[$this->vcodeSessionName]){ throw new Exception('验证码不正确。'); } if(!$_POST['parentId']) throw new Exception('链接错误'); $para=array( 'username'=>$_POST['username'], 'password'=>md5($_POST['password']), 'parentId'=>$_POST['parentId'], 'parentId'=>$_POST['qq'], 'parents'=>$this->getValue("select parents from {$this->prename}members where uid=?",$_POST['parentId']), 'fanDian'=>0, 'fanDianBdw'=>0, 'regIP'=>$this->ip(true), 'regTime'=>$this->time ); if(!$para['nickname']) $para['nickname']=$para['username']; if(!$para['name']) $para['name']=$para['username']; $this->beginTransaction(); try{ $sql="select username from {$this->prename}members where username=?"; if($this->getValue($sql, $para['username'])) throw new Exception('用户“'.$para['username'].'”已经存在'); if($this->insertRow($this->prename .'members', $para)){ $id=$this->lastInsertId(); $sql="update {$this->prename}members set parents=concat(parents, ',', $id) where `uid`=$id"; $this->update($sql); $this->commit(); return '注册成功'; }else{ throw new Exception('注册失败'); } }catch(Exception $e){ $this->rollBack(); throw $e; } }}
これは PHP コードですか?
QQ はバックグラウンドで追加できるが、プロモーション登録リンクは追加できないため、データベースにはこの値が含まれています。
'parentId'=>$_POST['parentId'], 'QQ'=>$_POST['qq'],
登録促進用のjsコードが貼り付けられていないのか、それとも機能が完全に実装されていないのか?
それは、テーブルにデータを書き込まないことを意味します
'parentId'=>$_POST['parentId'], 'QQ'=>$_POST['qq'],
理解できないので、説明してもらえますか?
'parentId'=>$_POST['parentId'],'parentId'=>$_POST['qq'],
ここで間違って書きました、正解は 2 階です
'parentId'=>$_POST['parentId'], 'QQ'=>$_POST['qq'],
ありがとう、ここで間違って書いてしまいました。
'parentId'=>$_POST['parentId'], 'QQ'=>$_POST['qq'],