【銅】第134篇 一對一視頻錄製及Ajax實現註冊周日

來源:互聯網
上載者:User

標籤:一對一視頻錄製   ajax實現註冊   

關鍵詞:一對一視頻錄製, Ajax實現註冊

一、一對一視頻錄製

1.1 需要做的

二、network

2.1 Ajax實現註冊,如下:

1)註冊html

         <h3>註冊請填寫:</h3>

         使用者名稱:<input type="text"   placeholder="請輸入使用者名稱" id="username1"

name="username" ><br>

         昵   稱:<inputtype="text"   placeholder="請輸入暱稱" id="nick1" name="nick" ><br>

         郵   箱:<inputtype="text"   placeholder="請輸入郵箱" id="email1"

name="email" ><br>

         電   話:<inputtype="text"   placeholder="請輸入電話" id="mobile1"

name="mobile" ><br>

         密   碼:<inputtype="password"  placeholder="請輸入密碼" id="pass1"

name="pass" ><br>

         確認密碼:<inputtype="password" placeholder="請再次輸入密碼" id="pass21"

name="pass2" ><br>

         <buttonid="formSubmit" onclick="tabSubmit()">提交</button>

2)tabSubmit函數如下:

   function tabSubmit(){

              var unameV =document.getElementById("username1").value;

                  varnickV = document.getElementById("nick1").value;

                  varemailV = document.getElementById("email1").value;

                  varmobileV = document.getElementById("mobile1").value;

                  varpassV = document.getElementById("pass1").value;

                  varpass2V = document.getElementById("pass21").value;

 

                  varform = new FormData();

                  form.append("username",unameV);

                  form.append("nick",nickV);

                  form.append("email",emailV);

                  form.append("mobile",mobileV);

                  form.append("pass",passV);

                  form.append("pass2",pass2V);

                  $.ajax({

                     url:"/0Web/index.php/user/UserRegData/saveUserInfo",

                      type:"post",

                      data:form,

                      processData:false,

                      contentType:false,

                      success:function(data){

                          if( data == 1001){

                  alert(‘您填寫的手機號或暱稱已存在,請檢查後重新填寫!!!‘);

                          }else if(data ==1002){

                   alert(‘插入成功!‘);

                  self.location="http://127.0.0.1/0Web/";//不跳轉直接把當前頁面頂掉

                          }else{

                             alert(‘系統錯誤,請稍後再試!‘);

                          }

                      },

                      error:function(e){

                          alert("錯誤!!");

                      }

                  }); 

   }

註:這個用ajax實現的插入,插入成功後,可以跳轉到首頁。

3)相關介面如下:

             //儲存使用者資訊

   public function saveUserInfo(){

       $data = $this->input->post();

       $username = $this->input->post("username");

       $nick = $this->input->get_post("nick");

       $email = $this->input->post("email");

       $mobile = $this->input->get_post("mobile");

       $pass = md5($this->input->post("pass"));

       $pass2 = md5($this->input->post("pass2"));

      $boolNick = $this->UsRgDtM->selectUser(‘nick‘,$nick);

      $boolMobile = $this->UsRgDtM->selectUser(‘mobile‘,$mobile);

       if($boolNick || $boolMobile){

               //1001 表示暱稱或手機號已存在

           $ret= 1001;

       }else{

               $bool =$this->UsRgDtM->saveUser($username,$nick,$email,$mobile,$pass,$pass2);

           if($bool){

                //1002 插入成功

                $ret = 1002;      

           }else{

                //1003 插入失敗

                $ret =  1003;

           }

       }

          echo json_encode($ret);

}

2017年5月14日星期日

436字 銅牌

【銅】第134篇 一對一視頻錄製及Ajax實現註冊周日

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.