This is my PHP script:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
$con=mysqli_connect($server,$username,$pass);
$connection=mysqli_select_db($con,$database);
$sql="SELECT * FROM `electric_database_users` WHERE
`User name/no`='".$_POST["username"]."' AND `Password`='".$_POST["password"]."'";
$result = $con->query($sql);
if ($result->num_rows > 0)
echo "login found";
else
echo "Invalid login";
$con->close();
?>
In javascript, I could fetch the data using $ajax
call:
$.ajax({
url: '/login_screen/backend.php',
type: 'POST',
data: { "input": "sign in",
"username": username,
"password": password},
success: function(response) {
if(response=="login found")
//Login successful
},
complete: function() {}
});
Now I want to implement the same logic from my android app i.e., I want to fetch the login details from my backend.php
. Is there something equivalent to $ajax
call in android?
empno=(EditText) findViewById(R.id.empno);
pass=(EditText) findViewById(R.id.pass);
login=(Button) findViewById(R.id.login);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//how do I proceed here?
}
});