2017-01-15 126 views
0

我正尝试将Android应用程序与WAMP服务器连接以访问数据库内容。在响应中运行代码后,它会提示为;我已经把WAMP在线,有Apache version 2.4.18。另外,WAMP图标是绿色的。我还在所有.conf文件中添加了Require all granted,但仍然无法正常工作。您没有权限访问此服务器上的check.php

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> 

代码

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()); 
       } 
      } 
     }); 
    } 
} 

我也受到phpmyadmin.conf文件中添加Alow from ::1尝试。但仍然没有工作。那里有吗?

回答

相关问题