所以这是我的问题。我有一个网站和一个android应用程序。我的用户需要在网站注册,所以我不需要在android部分创建一个注册页面,而只是登录页面。但是,每当我试图在浏览器上运行它以检查我是否得到了正确的响应时,login.php中就会出现错误--未定义的索引:用户名和未定义的索引:密码。我不知道wrong.Below是什么是我login.php的代码
<?php
include("config.php");
$decoded = json_decode(file_get_contents("php://input"));
$username = $decoded -> {"username"};
$password = $decoded -> {"password"};
$query = "SELECT u_id FROM pluma_user where password='$password' and username='$username'";
$result = mysql_query($query);
$obj = array();
$check = false;
while($row=mysql_fetch_assoc($result)){
$check = true;
$obj["result"] = "ok";
$obj["id"] = $row["u_id"];
}
if($check == false){
$obj["result"] = "failed";
}
$obj1 = array();
$obj1["result"] = "ok";
echo json_encode($obj);
mysql_close();
?>发布于 2014-02-18 02:12:13
试试这个来找出错误
使用
$result = mysql_query($query) or die (__LINE__." ".mysql_error());因此,如果查询中有任何错误,将显示查询行和查询错误代码,如果需要,可以添加__FILE__,但出于安全原因不建议使用它,并且应该在测试结束后将mysql_error更改为mysql_errno。
https://stackoverflow.com/questions/21842497
复制相似问题