I am developing a login and registration application in android studio by looking at some of video tutorials,and the php scripts are 100% as in the tutorial and it was working at first time, then now its not working.I can't identify what's gone wrong.. I am new to php and android
In the tutorial it's purely working. Tutorial link >>Registration app tutorial
spent more than two days for linking database, still stucked over, finally into stackoverflow, Hope for good Solution or Guidance. Thanks
init.php which is for Connection, and connection Success
<?php
$host = "localhost";
$user = "blood";
$password = "rifkan123";
$dbname = "userdb";
$con = mysqli_connect($host,$user,$password,$dbname);
if(!$con)
{
die("Error in Database Connection".mysqli_connect_error());
}
else
{
Echo "<h3> Database Connection Success !";
}
?>
login.php Script for login
<?php
$email = $_POST["email"];
$pass = $_POST["password"];
require "init.php";
$query = "Select * userinfo where email like. '".$email."';";
$result = mysqli_query($con,$query);
if(mysqli_num_rows($result)>0)
{
$response = array();
$code ="login_true";
$row = mysqli_fetch_array($result);
$name = $row[0];
$message ="Login Success ! Welcome ".$name;
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array(server_response=>$response));
}
else
{
$response = array();
$code ="login_false";
$message ="Login Failed ! Try Again";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array(server_response=>$response));
}
mysqli_close($con);
?>
register.php for user registration
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$pass = $_POST["password"];
require "init.php";
$query = "select * from userinfo where email like '".$email."';";
$result = mysqli_query($con,$query);
if(mysqli_num_rows($result)>0)
{
$response = array();
$code = "reg_false";
$message = "User Already Exist !";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array("server_response"=>$response));
}
else
{
$query = "insert into userinfo values('".$name."','".$email."','".$pass."');";
$result = mysqli_query($con,$query);
if(!$result)
{
$response = array();
$code = "reg_false";
$message = "Registration Failed, Try Again!";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array("server_response"=>$response));
}
else
{
$response = array();
$code = "reg_true";
$message = "Registration Success, Login to Continue!";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array("server_response"=>$response));
}
mysqli_close($con);
}
?>
I have missed the FROM in login script and after adding it new error detected Screen shot new Error