Beispiel #1
0
?>

<?php 
if (empty($_POST) === false) {
    $required_fields = array('first_name', 'username', 'password', 'retype_password', 'phoneno', 'address');
    foreach ($_POST as $key => $value) {
        if (empty($value) && in_array($key, $required_fields) === true) {
            $errors[] = 'Please fill in the required fields';
            break 1;
        }
    }
    if (empty($errors) === true) {
        if (filter_var($_POST['username'], FILTER_VALIDATE_EMAIL) === false) {
            $errors[] = 'Please enter a valid email address.';
        }
        if (users_exists($_POST['username']) === true) {
            $errors[] = 'Sorry the email \'' . $_POST['username'] . '\' is already used for registration.';
        }
        if (strlen($_POST['password']) < 6) {
            $errors[] = 'Please enter a password of at least 6 characters';
        }
        if ($_POST['password'] !== $_POST['retype_password']) {
            $errors[] = 'The passwords entered do not match.';
        }
    }
}
?>


<?php 
if (isset($_GET['success']) && empty($_GET['success'])) {
Beispiel #2
0
<?php

include 'core/init.php';
if (empty($_POST) === false) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    if (empty($username) === true || empty($password) === true) {
        $errors[] = 'Please enter a username and password';
        header('Location:index.php?err=' . $errors);
        exit;
    } else {
        if (users_exists($username) === false) {
            $errors[] = 'The username name entered does not seem match with our records. Please register before logging in.';
        } else {
            $login = login($username, $password);
            if ($login == false) {
                $errors[] = 'Either the username or the password entered is wrong. Please try to login again';
            } else {
                $_SESSION['user_id'] = $login;
                header('Location:home.php');
                exit;
            }
        }
    }
} else {
    $errors[] = 'Please enter the username and password';
}
include 'includes/overall/header.php';
?>

 <div class="jumbotron">