Я просто пытаюсь подключить свое Android-приложение к PHP-серверу на моем Localhost. Когда я делаю это, я получаю код ответа 501.
server.php
if(isset($_POST['email']) && isset($_POST['password'])){
$result = "";
$email = $_POST['email'];
$password = $_POST['password'];
$sql = "SELECT * FROM tbl_user where email='$email' AND password='$password'";
$result = $conn->query($sql);
if ($result->num_rows >0) {
while($row[] = $result->fetch_assoc()) {
$tem = $row;
$result = "true";
$json = json_encode($tem);
}
} else {
$result="false";
echo "No Results Found.";
}
echo $result;
echo $json;
}
My MainActivity
@Override
protected String doInBackground(String... params) {
'i am entering the ip of my pc'
url = new URL("http://192.168.0.1/test/server.php?");
conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
// Append parameters to URL using Uri.Builder and the
String query = builder.build().getEncodedQuery();
// Open connection for sending data
// my response_code value is 501
int response_code = conn.getResponseCode();
- when i run the code, my response_code value is 501
- i get IOException