使用php的app_live服务器连接 [英] app_live server connection using php

查看:161
本文介绍了使用php的app_live服务器连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

i尝试使用php连接我的服务器,问题是当用户通过登录页面验证时我无法启动新活动..它显示响应找到用户,但它没有打开指定的活动..有人可以指出代码中的错误,因为没有运行时错误...但我只是无法打开新活动,这是我的新类 - > insert_images.java

以下是我的login.java类

hello there,
i am trying to connect with my server using php, the problem is i am not able to start a new activity when user is verified through a login page.. it shows the response of user is found but it does not open the specified activity.. can some one point out the error in the code because there is no run time error... but i just cant open new activity that is my new class-->insert_images.java
following is my login.java class

void login() {
        try {
 
            httpclient = new DefaultHttpClient();
            httppost = new HttpPost("http://ar-expeditor-android-app.freeiz.com/check.php"); // make sure the url is correct.
            //add your data
            nameValuePairs = new ArrayList<>(2);
          
            nameValuePairs.add(new BasicNameValuePair("user_name", user_name.getText().toString().trim())); 
            nameValuePairs.add(new BasicNameValuePair("password", pass_admin.getText().toString().trim()));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            //Execute HTTP Post Request
            response = httpclient.execute(httppost);
            // edited by James from coderzheaven.. from here....
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
            final String response = httpclient.execute(httppost, responseHandler);
            System.out.println("Response : " + response);
            runOnUiThread(new Runnable() {
                public void run() {
                    tv.setText("Response from PHP : " + response);
                    dialog.dismiss();
                }
            });
                 response.trim();
          if (response.equalsIgnoreCase("congos...User Found...")) {
 
 
   Intent intent = new Intent(Login_admin.this, Insert_images.class);
 
                    
 
                        startActivity(intent);
 
                    }
 
 
        } catch (Exception e) {
            dialog.dismiss();
            System.out.println("Exception : " + e.getMessage());
        }
    }
 
    public void showAlert() {
        Login_admin.this.runOnUiThread(new Runnable() {
            public void run() {
                AlertDialog.Builder builder = new AlertDialog.Builder(Login_admin.this);
                builder.setTitle("Login Error.");
                builder.setMessage("User not Found... =(")
                        .setCancelable(false)
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                            }
                        });
                AlertDialog alert = builder.create();
                alert.show();
            }
and this is my php file...
 
<?php
$mysql_host = "mysql15.000webhost.com";
$mysql_database = "a9012246_arApp";
$mysql_user = "a9012246_sania";
$mysql_password = "sania1";
$localhost = mysql_connect($mysql_host,$mysql_user,$mysql_password)
or
trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($mysql_database, $localhost);
$user_name = $_POST['user_name'];
$password = $_POST['password'];
$query_search = "select * from login_admin where user_name = '".$user_name."' AND password = '".$password. "'";
$query_exec = mysql_query($query_search) or die(mysql_error());
$rows = mysql_num_rows($query_exec);
//echo $rows;
 if($rows == 0) {
 echo "No Such User Found";
 }
 else  {
  echo "congos...User Found... :p ";
}
?>
 
        });
    }

推荐答案

mysql_host = mysql15.000webhost.com;
mysql_host = "mysql15.000webhost.com";


mysql_database = a9012246_arApp;
mysql_database = "a9012246_arApp";


mysql_user = a9012246_sania;
mysql_user = "a9012246_sania";


这篇关于使用php的app_live服务器连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆