• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Need Help with Login App Using XML/HttpURL/PHP/SQL

ac4android

Well-Known Member
I am trying to create a login app using email and a password using HttpURL.
I am getting an email/password error back from the PHP I've created on the remote server.

Here is the XML that gets the email/password variables, the work well:
Code:
           <EditText
                android:id="@+id/et_email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/prompt_email"
                android:inputType="textEmailAddress"
                android:maxLines="1"
                android:singleLine="true" />

            <EditText
                android:id="@+id/et_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/email"
                android:layout_marginTop= "25dp"
                android:hint="@string/prompt_password"
                android:inputType="textPassword"
                android:maxLines="1"
                android:singleLine="true" />

Here is the part of the Android Java that grabs the email/login and send the pair to PHP:
JunkInLogin.JPG


And here is the PHP, it works, I tested it on Firefox,= & Chrome, it gives me the data if it gets the right email/password, else it tells me "Wrong email/password!". But it always return the result "Wrong email/password!" to my app.

Code:
$email = $_GET['email'];
$password = $_GET['password'];

$sql = "SELECT b.User_ID, b.User_Name, x.Unit_ID FROM Users b
   JOIN X_Users x ON TRIM(b.Email) = TRIM('$email') AND TRIM(b.Password) = TRIM('$password')";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) { 
   $response = array();
   while($row=mysqli_fetch_array($result)){
   array_push($response, array("User_ID"=>$row[0], "User_Name"=>$row[1], "Farm_ID"=>$row[2]));
   }
   echo json_encode(array("db_response"=>$response));
        echo'{"query_result":"Welcome back."}';
} else {
        echo'{"query_result":"Wrong email/password!"}';
};


PS 7/10/2017:
I forgot to add: JSON_STRING is null since PHP returns nothing. Worked myself into a rut again...
 
Last edited:
Back
Top Bottom