Android Question signup and login page whit B4A and PHP

Hi developers. I am really stuck in a bad problrm. I want to make signup and login page with B4A and PHP. I wrote the signup codes.but they did not work correctly.
actually the quary did not work. when i post the values with B4A. it does not return any eror. but nothing add into database.
2020-07-19_17-00-31.jpg

this is my PHP codes.
what should i do?
 

JohnC

Expert
Licensed User
Longtime User
Perform Basic troubleshooting:

1) First check to see if the PHP page is being accessed at all in response to the B4A doing a POST?
2) If so, then were the proper values passed from the B4A app to the PHP page?

These steps will FIRST narrow down if the problem is on the B4A side or the PHP side.
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
} else if ($count=0)
is a very unusual way do do a comparison, if that's what you thought you were doing. try it the right way and see if it matters. technically, if $count can only be 0 or >0, it might not matter.

also, can we see your b4a code? you might want to echo the things you POSTed to make sure they were received by the server.
also, is "old" or "ok" echoed? you didn't say.
also $insert is IMPORTANT. you never bother to find out its value. you say "ok", the server may have something else to say. $insert tells you that.
 
Upvote 0
I solve the problem.
I used the PDO instead mysqli.
This is my code:
<?php
$servername = "localhost";
$my_username = "";
$my_password = "";
$dbname = "";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $my_username, $my_password);


// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$conn->exec("SET NAMES utf8");


$id=$_POST['id'];
$username=$_POST['username'];
$password=$_POST['password'];


$stmt = $conn->prepare("INSERT INTO users_account VALUES ('".$id."','".$username."', '".$password."')");

$stmt->bindParam(':id', $id);
$stmt->bindParam(':username', $username);
$stmt->bindParam(':password', $password);


$stmt->execute();


echo "ok";
} catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>
 
Upvote 0
Top