【发布时间】:2015-11-30 09:28:20
【问题描述】:
我正在开发一个安卓应用程序的登录部分。有一个 PHP 页面使用 JSON 从应用程序获取输入并将其查询到 SQL 数据库并返回登录是否成功。
现在,我的老板不想要 PHP 页面,它必须是 ASP。
如何将 PHP 页面转换为使用 vbscript/javascript 的 ASP 页面?
我找到了http://www.aspjson.com/ 不知道如何转换 json_encode
PHP页面代码:
<?php mysql_connect("localhost","user","pass");
$db= mysql_select_db("database");
$androidID=$_POST["androidID"];
$username=$_POST["username"];
if (!empty($_POST)) {
if (empty($_POST['username']) || empty($_POST['androidID'])) {
// Create some data that will be the JSON response
$response["success"] = 0;
$response["message"] = "One or both of the fields are empty .";
//die is used to kill the page, will not let the code below to be executed. It will also
//display the parameter, that is the json data which our android application will parse to be
//shown to the users
die(json_encode($response));
}
$query = " SELECT id, username, aid FROM login WHERE username = '$username'and aid='$androidID'";
$sql1=mysql_query($query);
$row = mysql_fetch_array($sql1);
if (!empty($row)) { $response["success"] = 1;
$response["message"] = "You have been sucessfully login";
die(json_encode($response));
}
else{
$response["success"] = 0; $response["message"] = "invalid username or password ";
die(json_encode($response));
}
}
else{ $response["success"] = 0;
$response["message"] = " One or both of the fields are empty ";
die(json_encode($response));
}
mysql_close();
?>
【问题讨论】:
标签: javascript php json vbscript asp-classic