Skip to content

Instantly share code, notes, and snippets.

@wildroo
Created July 5, 2021 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wildroo/705cae41ef1632ee7fc0722298caa8bc to your computer and use it in GitHub Desktop.
Save wildroo/705cae41ef1632ee7fc0722298caa8bc to your computer and use it in GitHub Desktop.
<?php
header("Content-Type: application/json; charset=UTF-8");
include_once '../config/dbconfig.php';
include_once '../helpers/userHelper.php';
$db = new DBClass();
$userHelper = new UserHelper();
//$data = $connection->query('SELECT NOW()');
//print_r($data);
//main function
//catch action
//@var $request_method
$request_method = isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:'';
$data = json_decode(file_get_contents("php://input"),true);
if($request_method == "POST"){
//Get action method
$action = $_REQUEST['action'];
$connection = $db->getConnection();
switch ($action) {
case "createUser":
$json = $userHelper->createUser($connection, $data);
break;
case "resendActivationLink":
$json = $userHelper->resendActivationLink($connection, $data);
break;
case "activateUser":
$json = $userHelper->activateUser($connection, $data);
break;
case "changePassword":
$json = $userHelper->changePassword($connection, $data);
break;
case "validateUser":
$json = $userHelper->validateUser($connection, $data);
break;
default:
$json = array("success" => false, "Info" => "Request method not available!");
}
$connection = null;
echo json_encode($json);
}else{
$json = array("success" => false, "Info" => "Request method not accepted!");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment