Skip to content Skip to sidebar Skip to footer

Android Studio Doesn't Post To Localhost, And Doesn't Give An Error.

I have a basic registration script. It took me forever to get to this point, but I'm getting an 'error.' The app is supposed to send 3 strings of login registration to a localhost

Solution 1:

Change

$isAdmin ="no";
 $username="fakename";
 $password="fakepassword";
$isAdmin = isset($_POST["isAdmin"]);
$username = isset($_POST["username"]);
$password = isset($_POST["password"]);
echo$isAdmin;
echo$username;
echo$password;
$statement = mysqli_prepare($con, "INSERT INTO cresidentials (username,password,isAdmin) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($statement,'ssi',$username,$password,$isAdmin);
mysqli_stmt_execute($statement);
if(!$statement) { printf("Prepare failed: %s\n", mysqli_error($con)); }
echo"success";

To

if(isset($_POST["isAdmin"]) &&  isset($_POST["username"]) && isset($_POST["password"]))
{
    $username = isset($_POST["username"]);
    $password =  isset($_POST["password"]);
    $isAdmin = isset($_POST["isAdmin"]);

    $statement = mysqli_prepare($con, "INSERT INTO cresidentials (username,password,isAdmin) VALUES (?, ?, ?)");
    mysqli_stmt_bind_param($statement,'ssi',$username,$password,$isAdmin);
    mysqli_stmt_execute($statement);

    if(!$statement) 
    {
         printf("Prepare failed: %s\n", mysqli_error($con)); 
    }

    echo"success";
}
elseecho"values not set";

Post a Comment for "Android Studio Doesn't Post To Localhost, And Doesn't Give An Error."