summaryrefslogtreecommitdiffstats
path: root/login.php
blob: bbe1897c20878753230afb6a1f79717ccf3e5760 (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
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
<?php
	session_start();
	if(isset($_GET['logout']))
	{
		session_destroy();
		header('Location: login.php');
	}
	if(isset($_SESSION['username']))
	{
		header('Location: .');
	}
	if(isset($_POST['username']) && isset($_POST['password']))
	{
		$username = $_POST['username'];
		$password = $_POST['password'];
		require_once('vendor.inc.php');

		$user = UserQuery::create()->findOneByUsername($username);
		if ( !is_object($user) )
		{
			header('Location: login.php');
		}
		if($user->checkPassword($password))
		{
			$_SESSION['username'] = $username;
		}
		header('Location: .');
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>User</title>
<link rel="stylesheet" type="text/css" href="styles/style.css">
</head>
<body>
	<header><h1>Customer login</h1></header>
	<nav>
		<dl>
			<dt><a href="contact.php">Contact us</a></dt>
			<dt><a href="categories.php">Categories</a></dt>
			<dt><a href=".">Home</a></dt>
		</dl>
	</nav>
	<div id="content">
		<form action="login.php" method="post">
			<h1>User</h1>
			<div class="row">
				<label for="username"><u>U</u>sername:</label><input class="formw" type="text"
					placeholder="Username" id="username" name="username" accesskey="u"
					maxlength="100">
			</div>
			<div class="row">
				<label for="password"><u>P</u>assword:</label><input class="formw" type="password"
					placeholder="Password" id="password" name="password" accesskey="p">
			</div>
			<div class="spacer">&nbsp;</div>
			<button type="submit" accesskey="l">
				<u>L</u>ogin
			</button>
			<button type="reset" accesskey="r">
				<u>R</u>eset
			</button>
		</form>
		<div class="spacer"></div>
	</div>
	<footer>Copyright by SomeCompany Ltd.</footer>
</body>
</html>