Login Rest api using PHP and MySql

 

<?php
require_once('dbconfig.php');
$username = $_POST['username'];
$password = $_POST['password'];
$loginqry = "SELECT * FROM `users` WHERE `username`='$username' AND `password`='$password'";
$qry = mysqli_query($dbconn, $loginqry);
if(mysqli_num_rows($qry) > 0)
{
$userObj = mysqli_fetch_assoc($qry);
$response['status']=true;
$response['message']="Login success";
$response['data']=$userObj;
}
else
{
$response['status']=false;
$response['message']="User not found";
}
header('Content-Type: application/json; charset=UTF-8');
echo json_encode($response);
?>
view raw loginapi.php hosted with ❤ by GitHub





Comments

Popular posts from this blog

Your build is currently configured to use incompatible Java 21.0.3 and Gradle 8.2.1. Cannot sync the project.

Google Assistant Implementation in Android application with app actions