gpt4 book ai didi

javascript - E/Volley : [145] BasicNetwork. PerformRequest:https://的意外响应代码 404

转载 作者:太空宇宙 更新时间:2023-11-04 11:09:38 26 4
gpt4 key购买 nike

我的第一个帖子:Anything I try to store on database enters with value '0'

我解决了这个问题,但现在我遇到了另一个问题:为什么我尝试登录时出现此错误?

09-11 17:20:46.382 2577-5031/com.example.gustavo.loginregister D/NetworkSecurityConfig: No Network Security Config specified, using platform default
09-11 17:20:47.415 2577-5031/com.example.gustavo.loginregister E/Volley: [145] BasicNetwork.performRequest: Unexpected response code 404 for https://xxxxxxx.000webhostapp.com/Login.php
09-11 17:22:39.640 2577-6700/com.example.gustavo.loginregister E/Volley: [152] BasicNetwork.performRequest: Unexpected response code 404 for https://xxxxxxx.000webhostapp.com/Login.php

LoginActivity.java 文件:

package com.example.gustavo.loginregister;

import android.app.AlertDialog;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;

import org.json.JSONException;
import org.json.JSONObject;

public class LoginActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

final EditText edtEmail = (EditText) findViewById(R.id.edtEmail);
final EditText edtSenha = (EditText) findViewById(R.id.edtSenha);
final Button btnLogin = (Button) findViewById(R.id.btnLogin);
final TextView txtCadastreSe = (TextView) findViewById(R.id.txtCadastreSe);

txtCadastreSe.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent registroIntent = new Intent(LoginActivity.this, RegisterActivity.class);
LoginActivity.this.startActivity(registroIntent);
}
});

btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String email = edtEmail.getText().toString();
final String password = edtSenha.getText().toString();

Response.Listener<String> responseListener = new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonResponse = new JSONObject(response);
boolean success = jsonResponse.getBoolean("success");

if (success) {
String name = jsonResponse.getString("name");
String lastname = jsonResponse.getString("lastname");

Intent intent = new Intent(LoginActivity.this, UserAreaActivity.class);
intent.putExtra("name", name);
intent.putExtra("lastname", lastname);
intent.putExtra("email", email);
LoginActivity.this.startActivity(intent);

} else {
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
builder.setMessage("Login Failed")
.setNegativeButton("Retry",null)
.create()
.show();
}

} catch (JSONException e) {
e.printStackTrace();
}
}
};

LoginRequest loginRequest = new LoginRequest(email, password, responseListener);
RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
queue.add(loginRequest);
}
});
}
}

LoginRequest.java 文件:

package com.example.gustavo.loginregister;

import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;

import java.util.HashMap;
import java.util.Map;

public class LoginRequest extends StringRequest {
private static final String LOGIN_REQUEST_URL="https://wavecheck.000webhostapp.com/Login.php";
private Map<String, String> params;

public LoginRequest(String email, String password, Response.Listener<String> listener){
super(Method.POST, LOGIN_REQUEST_URL, listener, null);
params = new HashMap<>();
params.put("email", email);
params.put("password", password);
}

@Override
public Map<String, String> getParams() {
return params;
}
}

Login.php 文件:

<?php
require("Password.php");
$con = mysqli_connect("localhost", "xxx", "xxx", "xxxx");

$email = $_POST["email"];
$password = $_POST["password"];

$statement = mysqli_prepare($con, "SELECT * FROM user WHERE email = ?");
mysqli_stmt_bind_param($statement, "s", $email);
mysqli_stmt_execute($statement);
mysqli_stmt_store_result($statement);
mysqli_stmt_bind_result($statement, $colUserID, $colName, $colLastname, $colEmail, $colPassword);

$response = array();
$response["success"] = false;

while(mysqli_stmt_fetch($statement)){
if (password_verify($password, $colPassword)) {
$response["success"] = true;
$response["name"] = $colName;
$response["lastname"] = $colLastname;
$response["email"] = $colEmail;
}
}
echo json_encode($response);
?>

最佳答案

当您访问https://wavecheck.000webhostapp.com/Login.php时它不会直接返回 JSON。它返回一个 404 错误页面“这里还没有任何内容。该域名已准备好注册。”。这是来自主机的消息。显然您正在使用免费主机,并且“wavecheck”子域不存在。因此您需要重新托管您的 PHP 脚本,或者与免费主机联系以弄清楚发生了什么。

关于javascript - E/Volley : [145] BasicNetwork. PerformRequest:https://的意外响应代码 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46161957/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com