Changeset 47 for Dev/trunk/index.php


Ignore:
Timestamp:
07/25/11 15:47:15 (14 years ago)
Author:
fpvanagthoven
Message:

Login moved to index. Index content moved to mainmenu.php

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/index.php

    r44 r47  
    1 <?php require 'classes/master.php'; //should be at top of every page   
     1<?php
     2require 'classes/master.php'; //should be at top of every page
    23
    3 if(isset($_POST['login']))
    4 {
    5         if($_POST['username'] == '')
    6                 die("Please log in!");
    7         else
    8         {
    9                 $userDBI = new UserDatabaseInterface();
    10                 $user_exists = $userDBI->checkUserName($_POST['username']);
    11                 if($user_exists)
    12                 {       
    13                         $correct_password = $userDBI->checkUserPassword($_POST);
    14                         if(!$correct_password)
    15                                 die("The password you entered is not correct!");
    16                 }       
    17                 else
    18                         die("Unknown user name");
    19         }       
    20 }
    21 
    22 /* make an array of survey mock objects */
    23 $surveys = array();
    24 
    25 $surveyDBI = new SurveyDatabaseInterface(null);
    26 $surveyIDTitles = $surveyDBI->getExistingSurveys();
    27 
    28 
    29 foreach ($surveyIDTitles as $id => $title) {
    30     $survey = new Survey($id, $title);
    31     array_push($surveys, $survey);
     4if (isset($_POST['register'])) {
     5    if ($_POST['username'] != null && $_POST['password'] != null) {
     6        $userDBI = new UserDatabaseInterface();
     7        $user_exists = $userDBI->checkUserName($_POST['username']);
     8        if (!$user_exists) {
     9            $userDBI->addNewUser($_POST);
     10        }
     11        else
     12            echo "Username already exists, try something else";
     13    }
     14    else
     15        echo "please fill in a username and password";
    3216}
    3317?>
     
    4327    <body>
    4428        <div id="header">
    45                 <?php new Logo(); ?>
    46             </div>
    47        
     29<?php new Logo(); ?>
     30        </div>
     31
    4832        <div id="wrapper">
    49            
     33
    5034            <div id="content">
    51                 <div id="menu">               
    52                     <?php
    53                     SurveyButton::newSurveyButton();
    54                     SurveyButton::loadSurveyButton($surveys);
    55                     ?>
     35                <div id="menu">
     36                    <form action="mainmenu.php" method="POST">
     37                                        Username<br />
     38                        <input type="text" name="username"><br />
     39                                        Password<br />
     40                        <input type="password" name="password"><br/><br/><br/>
     41                        <input type="submit" name="login" class="surveyButton bigSurveyButton" value="Log in">
     42                    </form>
     43                    <form action="register.php" method="POST">
     44                        <input type="submit" name="register" class="surveyButton bigSurveyButton" value="Register">
     45                    </form>
    5646                </div>
    5747            </div>
Note: See TracChangeset for help on using the changeset viewer.