& Quot; success & quot;); e appphpandroid database
$ Conn = mysql_connect ("localhost", "root", "root ");
?>
Require 'Conn. php ';
If ($ _ POST ['username']! = "" & $ _ POST ['password']! = "")
{
$ Password = md5 ($ _ POST ['password']);
$ SQL = "select * from 'user' where username = '$ _ POST [username]'";
$ Query = mysqli_query ($ conn, $ SQL );
$ Row = mysqli_num_row ($ query );
If ($ row = 0 ){
$ Sql2 = "insert into 'user' (username, password) values ('$ _ POST [username]', '$ password ')";
$ Query = mysqli_query ($ conn, $ sql2 );
$ Result = array ("status" => "success ");
Echo json_encode ($ result );
}
Else {
$ Result = array ("status" => "exists ");
Echo json_encode ($ result );
}
}
?>
Public class register extends Activity {
@ Overrideprotected void onCreate (Bundle savedInstanceState) {// TODO Auto-generated method stub super. onCreate (savedInstanceState); CustomTitle ct = new CustomTitle (); ct. getTitleBar (this, "success", R. drawable. oval, R. drawable. oval, "��", "ȡ �"); setContentView (R. layout. signup); Button button1 = (Button) findViewById (R. id. button1); final EditText editText1 = (EditText) findViewById (R. id. editText1); final EditText editText2 = (EditText) findViewById (R. id. editText2); button1.setOnClickListener (new View. onClickListener () {@ Override public void onClick (View v) {// TODO Auto-generated method stub String username = editText1.getText (). toString (); String password = editText2.getText (). toString (); if (username. equals ("") | password. equals ("") {Toast. makeText (register. this, "the user name or password cannot be blank", Toast. LENGTH_LONG);} else {AsyncHttpClient client = new AsyncHttpClient (); RequestParams params = new RequestParams (); params. add ("username", username); params. add ("password", password); client. post (" http://192.168.1.203/NewsDemo/register.php ", Params, new AsyncHttpResponseHandler () {@ Override public void onSuccess (int arg0, Header [] arg1, byte [] arg2) {// TODO Auto-generated method stub String response = new String (); Log. e ("debug", response); JSONObject object = null; try {object = new JSONObject (response); String status = object. getString ("status"); if (status. equals ("exists") {Toast. makeText (register. this, "the user name already exists, please change", Toast. LENGTH_LONG);} else if (status. equals ("error") {Toast. makeText (register. this, "an error occurs. please try again later", Toast. LENGTH_LONG);} else {App. isLogin = true; Intent intent = new Intent (register. this, MainActivity. class); startActivity (intent); register. this. finish () ;}} catch (JSONException e) {// TODO Auto-generated catch block e. printStackTrace () ;}@ Override public void onFailure (int arg0, Header [] arg1, byte [] arg2, Throwable arg3) {// TODO Auto-generated method stub Toast. makeText (register. this, "network error", Toast. LENGTH_LONG );}});}}});}
}
Is there any problem with this code? I press the registration key, that is, button1 does not respond. the database log has received no feedback.
92.161.203--[28/Feb/2016: 22: 47: 44 + 0800] "POST/NewsDemo/register. php HTTP/1.1" 200 297 "-""-"
192.168.1.203--[28/Feb/2016: 22: 47: 45 + 0800] "POST/NewsDemo/register. php HTTP/1.1" 200 297 "-""-"
192.168.1.203--[28/Feb/2016: 22: 47: 45 + 0800] "POST/NewsDemo/register. php HTTP/1.1" 200 297 "-""-"
192.168.1.203--[28/Feb/2016: 22: 47: 47 + 0800] "POST/NewsDemo/register. php HTTP/1.1" 200 297 "-""-"
192.168.1.203--[28/Feb/2016: 22: 47: 47 + 0800] "POST/NewsDemo/register. php HTTP/1.1" 200 297 "-""-"
192.168.1.203--[28/Feb/2016: 22: 49: 31 + 0800] "POST/NewsDemo/register. php HTTP/1.1" 200 297 "-""-"
192.168.1.203--[28/Feb/2016: 22: 49: 32 + 0800] "POST/NewsDemo/register. php HTTP/1.1" 200 297 "-""-"
192.168.1.203--[28/Feb/2016: 22: 49: 34 + 0800] "POST/NewsDemo/register. php HTTP/1.1" 200 297 "-""-"