0% found this document useful (0 votes)
2 views3 pages

AuthoController PHP

The document defines an AuthController class that handles user authentication in a PHP application. It includes a login method that starts a session, retrieves username and password from POST data, and uses an AuthService to validate credentials. Upon successful login, it stores user information in session variables and outputs a success message.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

AuthoController PHP

The document defines an AuthController class that handles user authentication in a PHP application. It includes a login method that starts a session, retrieves username and password from POST data, and uses an AuthService to validate credentials. Upon successful login, it stores user information in session variables and outputs a success message.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

<?

php

require_once __DIR__ .

'/../../config/[Link]';

require_once __DIR__ .

'/../Services/[Link]';

class AuthController

private $authService;

public function __construct()

global $conn;

$this->authService =

new AuthService($conn);

public function login()

session_start();

$username =

$_POST['username'];
$password =

$_POST['password'];

$user =

$this->authService

->login(

$username,

$password

);

if (!$user) {

die(

"Invalid Credentials"

);

$_SESSION['user_id']

= $user['id'];

$_SESSION['role_id']

= $user['role_id'];

$_SESSION['school_id']

= $user['school_id'];
echo "Login Successful";

You might also like