コード例 #1
0
ファイル: register.php プロジェクト: hibonda/MovieShop
<?php

require_once 'Models/DataSetClient.php';
$view = new stdClass();
$view->pageTitle = 'Register';
/* Check for all fields if they are correctly filled and if so then create the user */
if (isset($_POST['register'])) {
    $emailAddress = $_POST['emailAddress'];
    $password = $_POST['password1'];
    $checkPassword = $_POST['password2'];
    $address = $_POST['address'];
    $mobileNumber = $_POST['mobileNumber'];
    /* Check if the user already exists in the DBS */
    $registerDataSetClient = new DataSetClient();
    $registered = $registerDataSetClient->checkClientExists($emailAddress);
    /* Message to be displayed */
    $view->result = null;
    /* Password requirements */
    $passUpperCase = preg_match('@[A-Z]@', $password);
    $passLowercase = preg_match('@[a-z]@', $password);
    $passNumber = preg_match('@[0-9]@', $password);
    /* Apply checks for the data received:
       empty form/fields, email address in the email field, registered user,
       password requirements, verify password again, numeric phone number */
    if (!empty($_POST['emailAddress']) && !empty($_POST['password1']) && !empty($_POST['password2']) && !empty($_POST['address']) && !empty($_POST['mobileNumber'])) {
        if (filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
            if ($registered == false) {
                if ($passUpperCase && $passLowercase && $passNumber && strlen($password) >= 8) {
                    if ($password == $checkPassword) {
                        if (is_numeric($mobileNumber)) {
                            /* If everything is correct, then create the user */
コード例 #2
0
ファイル: login.php プロジェクト: hibonda/MovieShop
<?php

/* Start the session */
session_start();
require_once 'Models/DataSetClient.php';
$view = new stdClass();
$view->pageTitle = 'Login';
/* Log out the user, if it clicks on Logout button */
if (isset($_POST['logout'])) {
    unset($_SESSION['username']);
}
/* Check if the user exists, if not then login the user */
if (isset($_POST['login'])) {
    $emailAddress = $_POST['username'];
    $password = $_POST['password'];
    $loginDataSetClient = new DataSetClient();
    $login = $loginDataSetClient->fetchClient($emailAddress, md5($password));
    if ($login !== false) {
        $_SESSION['username'] = $emailAddress;
    }
}
require_once 'Views/login.phtml';