コード例 #1
0
ファイル: userlogin.php プロジェクト: jian6/resturant_website
require_once 'WebsiteUser.php';
session_start();
if (isset($_SESSION['websiteUser'])) {
    if ($_SESSION['websiteUser']->isAuthenticated()) {
        session_write_close();
        header('Location:mailing_list.php');
    }
}
$missingFields = false;
if (isset($_GET['submit'])) {
    if (isset($_GET['username']) && isset($_GET['password'])) {
        if ($_GET['username'] == "" || $_GET['password'] == "") {
            $missingFields = true;
        } else {
            //All fields set, fields have a value
            $websiteUser = new WebsiteUser();
            if (!$websiteUser->hasDbError()) {
                $username = $_GET['username'];
                $password = $_GET['password'];
                $websiteUser->authenticate($username, $password);
                if ($websiteUser->isAuthenticated($username, $password)) {
                    $_SESSION['websiteUser'] = $websiteUser;
                    $lastLogin = date("y-m-d");
                    $websiteUser->lastLogin($username, $password, $lastLogin);
                    $_SESSION["username"] = $username;
                    $_SESSION["password"] = $password;
                    header('Location: mailing_list.php');
                }
            }
        }
    }
コード例 #2
0
ファイル: login.php プロジェクト: nipuns11/College-bakery
require_once 'WebsiteUser.php';
session_start();
if (isset($_SESSION['websiteUser'])) {
    if ($_SESSION['websiteUser']->isAuthenticated()) {
        session_write_close();
        header('Location:restricted.php');
    }
}
$missingFields = false;
if (isset($_POST['submit'])) {
    if (isset($_POST['username']) && isset($_POST['password'])) {
        if ($_POST['username'] == "" || $_POST['password'] == "") {
            $missingFields = true;
        } else {
            //All fields set, fields have a value
            $websiteUser = new WebsiteUser();
            if (!$websiteUser->hasDbError()) {
                $username = $_POST['username'];
                $password = $_POST['password'];
                $websiteUser->authenticate($username, $password);
                if ($websiteUser->isAuthenticated()) {
                    $_SESSION['websiteUser'] = $websiteUser;
                    header('Location:restricted.php');
                }
            }
        }
    }
}
?>

<!DOCTYPE html>
コード例 #3
0
<?php

require_once 'WebsiteUser.php';
require_once './contactDAO.php';
include 'header.php';
session_start();
session_regenerate_id(false);
?>

<div id="content" class="clearfix">
  <?php 
$websiteUser = new WebsiteUser();
echo 'Session ID: ' . session_id() . '<br>';
echo 'Admin ID: ' . $websiteUser->getInfo($_SESSION['username'], $_SESSION['password'])[0] . '<br>';
echo 'Last Login: '******'username'], $_SESSION['password'])[1] . '<br>';
//This section will display an HTML table containing all
//the customer in the mailingList table.
//
$contactDAO = new contactDAO();
$mailingList = $contactDAO->getContacts();
if ($mailingList) {
    //We only want to output the table if we have customer.
    //If there are none, this code will not run.
    echo '<div id="contactInfo">';
    echo '<table border=\'1\'>';
    echo '<tr><th>Customer ID</th><th>Name</th><th>Phone Number</th><th>Email</th><th>Referral</tr>';
    foreach ($mailingList as $contact) {
        echo '<tr>';
        echo '<td>' . $contact->getId() . '</td>';
        echo '<td>' . $contact->getName() . '</td>';
        echo '<td>' . $contact->getphone() . '</td>';