<repo_name>rahulyadav20111995/kalage_task<file_sep>/sign_in.php
<?php 

$servername = "localhost";
$username = "admin_joy";
$password = "<PASSWORD>";
$dbname ="kalage";

$conn=new mysqli($servername,$username,$password,$dbname);
 
//check connection
if($conn->connect_error)
{
	die("Connection failed: ".$conn->connect_error);
}


$user = $_POST['user'];
$pass = $_POST['pass'];

$query = "SELECT * FROM users WHERE `user_name`='$user' AND `password`='$pass'";
	$result=$conn->query($query);
	
	$jsonresponse=new stdClass();
	if($result->num_rows>0){
   		 $row=$result->fetch_array();
    		$jsonresponse->status=TRUE;
    		$jsonresponse->f_name=$row['first_name'];
    		$jsonresponse->email=$row['email'];
    		$jsonresponse->phone=$row['phone'];
            $jsonresponse->l_name=$row['last_name'];
           
			echo json_encode($jsonresponse);
	}
	else{
		echo "User not found . Please sign up first";
	}


?>
<file_sep>/sign_up.php
<?php 

$servername = "localhost";
$username = "admin_joy";
$password = "<PASSWORD>";
$dbname ="kalage";

$conn=new mysqli($servername,$username,$password,$dbname);
 
//check connection
if($conn->connect_error)
{
	die("Connection failed: ".$conn->connect_error);
}

$handle = $_POST['handle'];
$pass = $_POST['pass'];
$f_name = $_POST['f_name'];
$l_name = $_POST['l_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];

$query = "SELECT * FROM users WHERE `user_name`='$handle' OR `email`='$email'";
	$result=$conn->query($query);
	
	$query_rows = "SELECT * FROM users";
	$result_rows=$conn->query($query_rows);
	
	$newuserid = ($result_rows->num_rows)+1;
	
	
	if($result->num_rows==0){
   		 
		 
		 $insertUser = "INSERT into users VALUES('$newuserid','$handle','$f_name','$l_name','$phone','$email','$pass') ";
		$insertResult=$conn->query($insertUser);
		echo 'Registered ! Now Login!';
	}
	else{
		echo "Same User exist with handle or email id";
	}




?>