-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
67 lines (30 loc) · 873 Bytes
/
login.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require_once "header.php";
require_once "maincore.php";
require_once "includes/dbconnector.class.php";
$db=new DbConnector;
if( isset($_POST['register'] ) ){
$username=$_POST['username'];
$password=md5($_POST['password']);
$prepare=$db->mysqli->prepare("select user_id,password from tbl_user where username=?");
$prepare->bind_param('s',$username);
$prepare->execute();
$prepare->bind_result($uid,$pass);
$prepare->fetch();
$prepare->close();
if($password==$pass){
$_SESSION['user']['logged']=true;
$_SESSION['user']['uid']=$uid;
header('Location:index.php');
}else{
$_SESSION['error']['invalid']=true;
header('Location:login.php');
}
}else{
if( isset( $_SESSION['error']['invalid'])) {
$smarty->assign('invalid',true);
unset( $_SESSION['error'] ) ;
}
$smarty->display('template/login.tpl');
}
?>