source: Dev/branches/Demo/index.php @ 314

Last change on this file since 314 was 226, checked in by fpvanagthoven, 13 years ago
File size: 3.6 KB
Line 
1<?php
2require 'classes/master.php'; //should be at top of every page
3
4/*  Page still has ambiguous design. Login and Register buttons are at same hierarchy level, makes user suspect the register button works based on input given here.
5 *  Instead redirects to anoter page.
6 *   
7 */
8
9//Even voor tijdelijk, aangezien er nog pagina's missen en redirects daarom niet goed werken:
10//if (isset($_SESSION['userUid'])) {
11//    redirect("logout.php");
12//}
13
14$errorMessage[] = "";
15
16if (isset($_POST['register'])) {
17    /*
18      if (isset($_POST['username']) && isset($_POST['password'])) {
19      $dbi = new DatabaseInterface();
20      $user_results = $dbi->get("user", array("name" => $_POST['username']));
21      if (count($user_results) == 0 || !$user_results) {
22      if (strlen($_POST['password']) > 6) {
23      $user = new User(null, $_POST['username'], $_POST['password']);
24      $dbi->set($user);
25      $_SESSION['userUid'] = $user->uid;
26      } else {
27      $errorMessage[] = "Password is too short";
28      }
29      }
30      else
31      $errorMessage[] = "Username already exists, try something else!";
32      }
33      else
34      $errorMessage[] = "Please fill in a username and password";
35
36      }
37
38      }
39     */
40}
41
42if (isset($_POST['login'])) {   // User clicked the login button
43    /* $dbi = new DatabaseInterface();
44      $user_results = $dbi->get("user", array("name" => $_POST['username']));
45      if (isset($user_results[0])) {
46      if ($user_results[0]->password == $_POST['password']) {
47      $_SESSION['userUid'] = $user_results[0]->uid;
48      } else {
49      $errorMessage[] = "Incorrect password!";
50      }
51      } else {
52      $errorMessage[] = "Username doesn't exist!";
53      }
54      }
55
56      if (isset($_SESSION['userUid'])) {  // User just registered a new account
57      redirect('selectSession.php');
58      }
59
60
61     */
62    redirect('mainmenu.php');
63}
64?>
65
66<!DOCTYPE html>
67<html>
68    <head>
69        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
70        <title>Facilitator</title>
71        <?php new StyleSheet("visualeditors"); ?>
72        <script type="text/javascript" src="js/menu.js"></script>
73        <script type="text/javascript">
74       
75   
76
77        </script>
78    </head>
79    <body>
80        <div id="header">
81            <?php new Logo(); ?>
82        </div>
83
84        <div id="wrapper">
85
86            <div id="content">
87                <div class="largeFrame">
88                    <div class="largeTitle">Log in</div>
89                    <div class="content">
90                        <form action="index.php" method="POST">
91                            <h3>Username</h3>
92                            <input type="text" name="username"><br />
93                            <h3>Password</h3>
94                            <input type="password" name="password"><br/><br />
95                            <div id="errorDisplay">
96                                <?php
97                                foreach ($errorMessage as $message) {
98                                    echo "<h3 style='color: #FF0000;'>$message</h3>";
99                                }
100                                ?>
101                            </div>
102                            <br/>
103                            <input type="submit" name="login" class="bigButton vertical" value="Log in">
104                        </form>
105                        <form action="register.php" method="POST">
106                            <input type="submit" name="register" class="bigButton vertical" value="Register" style="margin-bottom: 0.25em;">
107                        </form>
108                    </div>
109
110                </div>
111            </div>
112        </div>
113    </body>
114</html>
Note: See TracBrowser for help on using the repository browser.