I am trying to connect Android Application with WAMP server for accessing DB content. After running the code in the response it is prompting as; I have put WAMP online, having Apache version 2.4.18
. Also, WAMP icon is green. I also added Require all granted
in all .conf
files but still it is not working.
V/REGISTERActivity: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /check.php
on this server.<br />
</p>
<hr>
<address>Apache/2.4.18 (Win64) PHP/5.6.19 Server at 192.168.11.100 Port 80</address>
</body></html>
phpmyadmin.conf
Alias /phpmyadmin "c:/wamp64/apps/phpmyadmin4.5.5.1/"
<Directory "c:/wamp64/apps/phpmyadmin4.5.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
# To import big file you can increase values
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
</Directory>
phpsysinfo
Alias /phpsysinfo "c:/wamp64/apps/phpsysinfo3.2.5/"
<Directory "c:/wamp64/apps/phpsysinfo3.2.5/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
adminer.conf
Alias /adminer "c:/wamp64/apps/adminer4.2.4/"
<Directory "c:/wamp64/apps/adminer4.2.4/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Code
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class MainActivity extends AppCompatActivity {
private static final String BASE_URL = "http://192.168.11.100/check.php";
private OkHttpClient client = new OkHttpClient();
EditText userNameTextEdit, passwordTextEdit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//
userNameTextEdit = (EditText) findViewById(R.id.usenameText);
passwordTextEdit = (EditText) findViewById(R.id.passwordText);
Button login = (Button) findViewById(R.id.buttonlogin);
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// handle login
String username = userNameTextEdit.getText().toString();
String password = passwordTextEdit.getText().toString();
registerUser(username, password);
}
});
}
public void registerUser(String username, String password) {
RequestBody body = new FormBody.Builder()
.add("username", username)
.add("password", password)
.build();
Request request = new Request.Builder().url(BASE_URL).post(body).build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
System.out.println("Registration Error" + e.getMessage());
}
@Override
public void onResponse(Call call, Response response) throws IOException {
try {
String resp = response.body().string();
Log.v("REGISTERActivity", resp);
// userNameTextEdit.setText(resp);
System.out.println(resp);
if (response.isSuccessful()) {
} else {
}
} catch (IOException e) {
// Log.e(TAG_REGISTER, "Exception caught: ", e);
System.out.println("Exception caught" + e.getMessage());
}
}
});
}
}
I also tried by adding Alow from ::1
in phpmyadmin.conf file. But still not working. Any there?
Your wamp server does not allow to request. You need to configure your server. check out following answer. it might help you. WAMP error: Forbidden You don't have permission to access /phpmyadmin/ on this server
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.