Esempio n. 1
0
<?php

require_once 'bootstrap.php';
use Assignment\UsernameValidator;
use Assignment\PasswordValidator;
use Assignment\EmailValidator;
use Assignment\URLValidator;
use Assignment\DateValidator;
use Assignment\Registration;
use Assignment\User;
$user = new User();
if ($_POST) {
    $data = array('username' => new UsernameValidator($_POST['username'], true, 0, 20), 'password' => new PasswordValidator($_POST['password'], true, 0, 20), 'email' => new EmailValidator($_POST['email'], true), 'URL' => new URLValidator($_POST['url']), 'DOB' => new DateValidator($_POST['dob'], true, 18));
    $reg = new Registration($data);
    if (empty($reg->getErrors())) {
        $user->login($data);
        $errors = array();
    } else {
        $errors = $reg->getErrors();
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Registration Form</title>
  <style>
    fieldset {padding:3px}
    input {display:block; margin: 0 auto 10px auto}
    label {display:block; margin-bottom: 2px}