我已经解决这个问题有一段时间了,目前正在尝试将我的 php 脚本转换为 PDO,但在运行 isset() 时 $_POST 总是给我 null。我在 android 中的代码与我的其他脚本一起工作得很好,但是当我将每个项目上的 $_POST 更改为 $_REQUEST 并且链接看起来也不同时,这个代码只能在邮递员中工作。还值得一提的是 onResponse 和 onFailure 不会接收/打印任何消息。
邮递员网址
http://123.456.7.89/Database/register.php?username=asdfasdf&password=lj4ioidfoislkjsf&email=jalenpauloiudf&tece=true&profilePicPath=aksdfjlakjdsfl&tokenId=as89gwbeg98sd
当前网址
http://123.456.7.89/Database/register.php
脚本
<?php
$servername = "localhost";
$dbUsername = "root";
$dbPassword = "password";
$dbname = "Database";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $dbUsername, $dbPassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$termsOfService = $_POST['termsOfService'];
$profilePicPath = $_POST['profilePicPath'];
$tokenId = $_POST['tokenId'];
$userId = uniqId();
//converting data
$termsOfService = $termsOfService ? 'true' : 'false';
//Username check
$emailForQuery = "%" . $_POST['email'] . "%";
$userIdForQuery = "%" . $userId . "%";
$usernameCheckQuery = $conn->prepare("SELECT email, userId FROM users WHERE email LIKE ? OR userId LIKE ? LIMIT 1");
$usernameCheckQuery->execute([$emailForQuery, $userIdForQuery]);
$usernameCheckQuery->fetch();
Cats萌萌
蛊毒传说