//regiser
<!-头部->{include file="public:header"/}<!-导航->{include file="public:nav"/}<div class= "col-md-8"> <div class="page-header text-center"> <h2>用户注册</h2> </div> <form class="form-horizontal" method='post' id="login"> <div class="form-group"> <label for="inputEmail1" class="col-sm-2 control-label">用户:</label> <div class="col-sm-10"> <input type="text" name="name" class="form-control" id="inputEmail1" placeholder="username"> </div> </div> <div class="form-group"> <label for="inputEmail2" class="col-sm-2 control-label">邮箱:</label> <div class="col-sm-10"> <input type="text" name="email" class="form-control" id="inputEmail2" placeholder="E-mel"> </div> </div> <div class="form-group"> <label for="inputEmail3" class="col-sm-2 control-label">手机:</label> <div class="col-sm-10"> <input type="text" name="mobile" class="form-control" id="inputEmail3" placeholder="Mudah alih"> </div> </div> <div class="form-group"> <label for="inputEmail4" class="col-sm-2 control-label">密码:</label> <div class="col-sm-10"> <input type="password" name="password" class="form-control" id="inputEmail4" placeholder="Kata Laluan"> </div> </div> <div class="form-group"> <label for="inputEmail5" class="col-sm-2 control-label">确认密码:</label> <div class="col-sm-10"> <input type="password" name="password_confirm" class="form-control" id="inputEmail5" placeholder="Password_confirm"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-default" id="register">注册</button> </div> </div> </form></div><skrip> $(function () { $("#register").on('klik',function () { alert($('#login').serialize()); $.ajax({ type:' post' url:"{:url('index/user/insert')}", data:$('#login').serialize(), dataType:'json', success: success: 功了') } }) }) })</script>{include file="public:rigt"/}{include file="public:footer"/}
/🎜 *** halaman pendaftaran*/namespace appindexcontroller;gunakan appcommoncontrollerBase;gunakan appcommonmodelUser sebagai UserModel;gunakan thinkfacadeRequest;class User extends Base{ public function register() { $this ->assign('title','用户注册'); return $this ->fetch(); } public function insert() { if ( Request ::isAjax()){ $data = Request::except('password_confirm','post'); if(UserModel::create($data)) { return ['status'=> 1, 'message'=> '注册成功']; }lain{ kembali ['status'=> 0, 'message'=> '注册失败']; } }lain{ $ini -> error("请求类型错误",'daftar'); } }}🎜
Kod anda terlalu kemas dan tiada versi TP yang anda muat turun. Anda boleh membungkus keseluruhan projek dan menghantarnya kepada saya.
Versi semasa thinkphp sudah 6. Anda boleh belajar versi 6.
Mengikut soalan anda, jika operasi PHP tidak selesai dan ralat dilaporkan, pasti tiada kotak timbul dalam kod JS.
Sila lihat kod php dahulu untuk melihat jika terdapat sebarang ralat. F12 pelayar boleh dilihat.