的错误是::
public function actionGetUserLogin()
{
// array for JSON response
$response = array();
$conn=mysqli_connect("localhost","root","","db");
$user_login = "select * from user" ;
$query = mysqli_query ($conn, $user_login);
while($results = mysqli_fetch_array ($query)){
$user_name = $results['mobile_user_name'];
$pass = $results['mobile_user_pass'];
echo $user_name;
echo "";
echo $pass;
echo "";
}
//compare the POST data from user with the existing username and password in database table
if($_POST['username']==$user_name&&$_POST['username']!=""&&$_POST['password']==$pass&&$_POST['password']!="")
{
//if match with database record
$response["success"] = 1;
$response["message"] = "correct";
}else{
$response["success"] = 0;
$response["message"] = "wrong";
}
echo json_encode($response);
Yii::app()->end();
}
当我使用这个网址测试这个方法,我得到一个错误未定义指数:用户名
是它接受json时,我的php出错了? 有没有办法显示android发送的json数据?
2015-03-31
imcrazy
+0
你必须确保表单使用post方法。 –
2015-03-31 22:54:09