Código PHP:
getValuePairs().add(newBasicNameValuePair("LogMail",user.getMail()));
getValuePairs().add(new BasicNameValuePair("LogPass",user.getPassword()));
Log.v("Señal", "NameValuePairs Listas " +getValuePairs().get(0).toString() + " " + getValuePairs().get(1)); //Muestro variables
setWebPost(new HttpPost("http://www.misitio.com/login.php"));
try{
getWebPost().setEntity(new UrlEncodedFormEntity(getValuePairs()));
setWebResponse(getClient().execute(getWebPost()));
setResult(EntityUtils.toString(getWebResponse().getEntity()));
String aux = getResult();
Log.v("Señal","Este es el valor de la respuesta " + aux);
if(!getResult().equals("")){
return true;
}
}catch(Exception e){
setResult(e.toString());
}
return false;
Código PHP:
<?php
$user = "498434";
$pass = "****";
$host = "localhost";
$db = "498434";
$email = $_REQUEST['LogMail'];
$password = $_REQUEST['LogPass'];
if(isset($email) && isset($password)){
$con = mysql_connect($host,$user,$pass) or die("DB connection failed: ".mysql_error());
mysql_select_db($db,$con) or die("Problem accessing DB ".mysql_error());
$result = mysql_query("SELECT * FROM Usuario WHERE Email = '$email' AND Password = '$password'",$con) or die("Query Problems ".mysql_error());
if(mysql_num_rows($result) > 0){
echo "Logged";
}else{
echo " ";
}
mysql_close($con);
}else{
echo "Valores nulos";
}
?>