diff --git a/Amysql/Function.php b/Amysql/Function.php index 079cd10..0b438f4 100644 --- a/Amysql/Function.php +++ b/Amysql/Function.php @@ -60,7 +60,7 @@ function RandSting($l = 10) { */ function Json($data) { header ( 'Content-Type:application/json; charset=' . Config ( 'Charset' ) ); - exit ( json_encode ( $data, 0 ) ); + exit ( json_encode ( $data ) ); } /** diff --git a/Controller/user_public.php b/Controller/user_public.php index 0a9e2fe..308f1c3 100644 --- a/Controller/user_public.php +++ b/Controller/user_public.php @@ -1,12 +1,14 @@ _model ( "authme" )->register ( $_REQUEST ['user'], md5 ( $_REQUEST ['pass'] ), $_REQUEST ['mail'], GetUserIP () )) + if ($this->_model ( "authme" )->register ( $_REQUEST ['user'], md5 ( $_REQUEST ['pass'] ), $_REQUEST ['mail'], GetUserIP () )){ $_SESSION ['username'] = $_REQUEST ['user']; - $_SESSION ['mail'] = $_REQUEST ['mail']; - $_SESSION ['ip'] = GetUserIP (); - JsonSuccess ( 'Minecraft帐号注册成功' ); - JsonError ( 'Minecraft帐号注册失败' ); + $_SESSION ['mail'] = $_REQUEST ['mail']; + $_SESSION ['ip'] = GetUserIP (); + JsonSuccess ( 'Minecraft帐号注册成功' ); + }else{ + JsonError ( 'Minecraft帐号注册失败' ); + } } function login() { if ($this->_model ( "authme" )->login ( @$_REQUEST ['user'], md5 ( @$_REQUEST ['pass'] ) )) { diff --git a/Model/authme.php b/Model/authme.php index 9411bb3..b064ed5 100644 --- a/Model/authme.php +++ b/Model/authme.php @@ -24,7 +24,6 @@ class authme extends AmysqlModel { 'time' => date ( 'Y-m-d' ), "user" => $username ); - if ($this->_insert ( 'authme', $value ) == 0) { return false; } else { @@ -40,7 +39,7 @@ class authme extends AmysqlModel { } } public function login($username, $password) { - if ($this->_sum ( "select * from `authme` where `username` = '$username' and `password` = '$password'" ) == 0) + if ($this->_sum ( "SELECT * FROM `authme` WHERE `username` = '$username' AND `password` = '$password'" ) == 0) return false; else @@ -51,7 +50,7 @@ class authme extends AmysqlModel { "password" => $newpass ); - $num = $this->_update ( 'authme', $key, "where username='" . $username . "'" ); + $num = $this->_update ( 'authme', $key, "WHERE username='" . $username . "'" ); if ($num == 0) return false; return true; @@ -60,14 +59,14 @@ class authme extends AmysqlModel { $key = array ( "password" => $value ); - $num = $this->_update ( 'authme', $key, "where username='" . $username . "'" ); + $num = $this->_update ( 'authme', $key, "WHERE username='" . $username . "'" ); // print_r($key); if ($num == 0) return false; return true; } public function check_user($user) { - $sum = $this->_sum ( "select * from `authme` where `username` = '" . $user . "'" ); + $sum = $this->_sum ( "SELECT * FROM `authme` WHERE `username` = '" . $user . "'" ); if ($sum == 0) return true; return false; diff --git a/View/register.php b/View/register.php index 2646d19..6ebdd21 100644 --- a/View/register.php +++ b/View/register.php @@ -106,7 +106,6 @@ $("#register").click(function(){ } $.ajax({ url:"", type:"GET", data:{user:username.val()}, dataType:"json", success:function(rdata){ - alert("checkusersuccess"); switch(rdata.status){ case "success": $.ajax({url:"", type:"GET", data:{mail:email.val()}, dataType:"json", @@ -144,8 +143,8 @@ $("#register").click(function(){ }, error:function(){ alert("checkusererror"); - }) -}) + }}) + }) \ No newline at end of file