source: Dev/trunk/mainmenu.php @ 58

Last change on this file since 58 was 58, checked in by fpvanagthoven, 14 years ago

mainmenu.php tweaked for usability. When not logged in, the user gets redirected to index.php

File size: 1.7 KB
Line 
1<?php
2require 'classes/master.php'; //should be at top of every page   
3
4if (isset($_POST['login'])) {
5    if ($_POST['username'] == '')
6        die("Please log in!");
7    else {
8        $userDBI = new UserDatabaseInterface();
9        $user_exists = $userDBI->checkUserName($_POST['username']);
10        if ($user_exists) {
11            $correct_password = $userDBI->checkUserPassword($_POST);
12            /* session remembers login */
13            if (!$correct_password)
14                die("The password you entered is not correct!");
15            else
16                $_SESSION['username'] = $_POST['username'];
17        }
18        else
19            die("Unknown user name");
20    }
21}
22else if (is_null($_SESSION['username']))
23    redirect('index.php');
24
25$surveys = array();
26
27$surveyDBI = new SurveyDatabaseInterface(null);
28$surveyIDTitles = $surveyDBI->getExistingSurveys();
29
30
31foreach ($surveyIDTitles as $id => $title) {
32    $survey = new Survey($id, $title);
33    array_push($surveys, $survey);
34}
35?>
36
37<!DOCTYPE html>
38<html>
39    <head>
40        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
41        <title>Facilitator</title>
42        <link rel="stylesheet" type="text/css" href="css/style.css" />
43        <script type="text/javascript" src="js/menu.js"></script>
44    </head>
45    <body>
46        <div id="header">
47            <?php new Logo(); ?>
48        </div>
49
50        <div id="wrapper">
51
52            <div id="content">
53                               
54                    <?php new SessionMenu(); ?>
55
56                    <?php new ApplicationMenu(); ?>
57               
58                    <?php new SurveyMenu($surveys); ?>
59
60            </div>
61        </div>
62    </body>
63</html>
Note: See TracBrowser for help on using the repository browser.