I have created a login and register screen using sql as database and php as scripting language. Java code on android works perfectly but when I input user information on register screen and hit register button, the data is not inserted into my database. So I am assuming that there is something wrong with my php files.
Below is my php file:
require "connection.php";
$first_name = $_GET['first_name'];
$last_name = $_GET['last_name'];
$email = $_GET['email'];
$password = $_GET['password'];
$mobile_no = $_GET['mobile_no'];
$carplate_no = $_GET['carplate_no'];
if($first_name == '' || $last_name == '' || $email == '' || $password == ''
|| $mobile_no == '' || $carplate_no == '')
{
echo 'Please fill all values';
}
else {
$sql = "SELECT * FROM Users WHERE email='$email' OR password='$password'";
$check = mysqli_fetch_array(mysqli_query($connection,$sql));
if(isset($check)){
echo 'email already exists';
}
else{
$sqli="INSERT INTO Users (first_name,last_name,email,password,mobile_no,carplate_no) VALUES ('$first_name','$last_name','$email','$password','$mobile_no','$carplate_no')";
if(mysqli_query($connection,$sql)){
echo'Registered Successfully';
}
else {
echo 'Oops...Try again';
}
}
mysqli_close($connection);
}
?>