aboutsummaryrefslogtreecommitdiffstats
path: root/php/login.php
blob: c26445ec359d0478ef4fceeada43fad1ab92025b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require_once "user.php";
require_once "database.php";
require_once "misc.php";

session_start();

$username=$_POST["username"];
$password=$_POST["password"];
/*server side verification*/
if(gettype($username)!="string" || gettype($password)!="string")
{
	die("You didn't specify the pass or the username");
}

$database=new Database();
$user=$database->authenticate($username,$password);
if(!$user)
{
	die("Password or username is incorrect");
}

$_SESSION['username'] = $user->username;
$_SESSION['user_object'] = $user;

header('Location: /');

?>