File: /var/www/selfanalyse/school-admin/backend/authenticate_login.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include_once('../../wp-config.php');
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
$json = file_get_contents('php://input');
$data = json_decode($json);
if(isset($data)){
$user_name = $data->user_login;
$password = $data->user_pass;
$verfiyUser = "SELECT school_id,username,password from wp_psy_school where username='$user_name' OR password='$password'";
$userData = $wpdb->get_row($verfiyUser);
$userReg = $userData->username;
$userPwd = $userData->password;
if ($user_name != $userReg) {
$revertArray[] = array("status"=>"0","message"=>"Incorrect Username");
} else if ($password != $userPwd) {
$revertArray[] = array("status"=>"0","message"=>"Incorrect Password");
} else {
session_start();
$session_id = uniqid();
$_SESSION['user_login'] = $userReg;
$_SESSION['user_id'] = $userData->school_id;
$revertArray[] = array("status"=>"1","message"=>"Successfully Logged In");
}
echo json_encode($revertArray);
}