function process() { if ($this->_input->post("Login")) { $userName = $this->_input->post('user_name'); $passwd = md5($this->_input->post('passwd')); $this->_template->set_var("user_name", $userName); $checkArray = array('user_name' => 'Username', 'passwd' => 'Password'); if ($this->_jScript->checkFilds($checkArray)) { $userCtrl = new UserController(); $userEnt = $userCtrl->loginUser($userName, $passwd); if (is_object($userEnt)) { $userObj = $userCtrl->createUser($userEnt); $_SESSION['REGI_userObject'] = serialize($userObj); $sessionObj = unserialize($_SESSION['REGI_userObject']); if (is_object($sessionObj)) { if ($sessionObj->getActive() == 0) { $this->redirect('UserActivate'); } else { $this->redirect('Radio'); } } } else { $this->_jScript->alert("Ingevoerde gebruikersnaam en/of wachtwoord is/zijn niet correct!"); } } } $this->_template->parse($this->_outputName, $this->_mainBlock); }
<?php /** * Created by PhpStorm. * User: Haziq * Date: 10/22/2015 * Time: 10:22 AM */ require_once $_SERVER['DOCUMENT_ROOT'] . '/WoofWorrior/ControllerClasses/UserController.php'; if (isset($_POST['Username'])) { $name = $_POST['Username']; $string = str_replace(' ', '-', $name); // Replaces all spaces with hyphens. $string = preg_replace('/[^A-Za-z0-9\\-]/', '', $string); // Removes special chars. $string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one. $Object = new UserController(); $result = $Object->loginUser($string); echo json_encode($result); }
/** * login user * * @return json * */ public function loginUser($input) { $User = parent::loginUser(json_decode($input, true)); return $this->buildAnswer($User[0], $User[1]); }
<?php //returns JSON object stating whether user was able to be logged in or not. include "controllers/user.controller.php"; $users = new UserController(); $login = $users->loginUser($_POST['email'], $_POST['password']); echo json_encode($login);