summaryrefslogtreecommitdiffstats
path: root/login.php
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-05-18 00:42:16 +0200
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-05-18 00:42:16 +0200
commit86042acca2f45f1153104941a17677ae01c91c9d (patch)
tree016ecca16603a4d1c695dc3c02cf130b8d2ae27d /login.php
parent6f33d7efdbfe7d26097ebefe95a9d8d38b111fba (diff)
downloadCatalog-86042acca2f45f1153104941a17677ae01c91c9d.tar.gz
Catalog-86042acca2f45f1153104941a17677ae01c91c9d.zip
PHPify everything and add user login
Diffstat (limited to 'login.php')
-rw-r--r--login.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/login.php b/login.php
new file mode 100644
index 0000000..bbe1897
--- /dev/null
+++ b/login.php
@@ -0,0 +1,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> \ No newline at end of file