/
login.php
73 lines (64 loc) · 1.73 KB
/
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
68
69
70
71
72
73
<?php
/*
Copyright "Clients" 2010
Made by Tom Arnfeld :)
http://tarnfeldweb.com/
twitter.com/tarnfeld
If you have any feauture requests, pop along to tarnfeld@me.com :P
Thanks!
*/
include('includes/db.php');
$_ERROR = array();
if($_POST)
{
$num = 0;
foreach($_POST as $key=>$value)
{
if(strlen(str_replace(" ","",$value))<=0)
{
$_ERROR[$key] = 'class="error"';
$num ++;
}
}
if($num>0)
{
$_ERROR['text'] = 'Please fill in all fields';
}
else
{
$sql = "SELECT * FROM `staff` WHERE email='$_POST[email]' AND `active`='1'";
$result = mysql_query($sql,$mysql);
$num = mysql_num_rows($result);
if($num>0)
{
$data = mysql_fetch_assoc($result);
$_SESSION['user']['loggedin'] = true;
$_SESSION['user']['id'] = $data['id'];
$_SESSION['user']['name'] = $data['name'];
header("Location: index.php");
}
else
{
$_ERROR['text'] = 'Invalid Credentials';
$_ERROR['email'] = 'class="error"';
$_ERROR['password'] = 'class="error"';
}
}
}
$_TAG['title'] = $_CONFIG['company'].' | Login';
$_TAG['file'] = 'login.php';
include('includes/head.php');
?>
<div id="loginbox">
<h1><?=$_CONFIG['company']?></h1>
<div class="content">
<h2>Login <span class="error"><?=$_ERROR['text']?></span></h2>
<form method="post" action="login.php">
<input <?=$_ERROR['email']?> placeholder="Email" value="<?=$_POST['email']?>" type="text" name="email" />
<input <?=$_ERROR['password']?> placeholder="Password" value="<?=$_POST['password']?>" type="password" name="password" />
<button type="submit">Login</button>
<a href="forgot.php"><button style="float:right;" type="button">Forgot</button></a>
</form>
</div>
</div>
<? include('includes/footer.php'); ?>