Ejemplo n.º 1
0
<?php

use PhpSolutions\Authenticate\CheckPassword;
if (isset($_POST['register'])) {
    $username = trim($_POST['username']);
    $password = trim($_POST['pwd']);
    $retyped = trim($_POST['conf_pwd']);
    require_once '../PhpSolutions/Authenticate/CheckPassword.php';
    $checkPwd = new CheckPassword($password, 10);
    $passwordOK = $checkPwd->check();
    if ($passwordOK) {
        $result = ['Password OK'];
    } else {
        $result = $checkPwd->getErrors();
    }
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>Register User</title>
    <style>
        label {
            display:inline-block;
            width:125px;
            text-align:right;
            padding-right:2px;
        }
        input[type="submit"] {
            margin-left:135px;
Ejemplo n.º 2
0
<?php

use PhpSolutions\Authenticate\CheckPassword;
require_once __DIR__ . '/../PhpSolutions/Authenticate/CheckPassword.php';
$usernameMinChars = 6;
$errors = [];
if (strlen($username) < $usernameMinChars) {
    $errors[] = "Username must be at least {$usernameMinChars} characters.";
}
if (preg_match('/\\s/', $username)) {
    $errors[] = 'Username should not contain spaces.';
}
$checkPwd = new CheckPassword($password, 10);
$checkPwd->requireMixedCase();
$checkPwd->requireNumbers(2);
$checkPwd->requireSymbols();
$passwordOK = $checkPwd->check();
if (!$passwordOK) {
    $errors = array_merge($errors, $checkPwd->getErrors());
}
if ($password != $retyped) {
    $errors[] = "Your passwords don't match.";
}
if (!$errors) {
    // include the connection file
    require_once 'connection.php';
    $conn = dbConnect('write', 'pdo');
    // create a key
    $key = 'takeThisWith@PinchOfSalt';
    // prepare SQL statement
    $sql = 'INSERT INTO users_2way (username, pwd)
Ejemplo n.º 3
0
<?php

use PhpSolutions\Authenticate\CheckPassword;
if (isset($_POST['register'])) {
    $username = trim($_POST['username']);
    $password = trim($_POST['pwd']);
    $retyped = trim($_POST['conf_pwd']);
    require_once '../PhpSolutions/Authenticate/CheckPassword.php';
    $checkPwd = new CheckPassword($password, 10);
    $checkPwd->requireMixedCase();
    $checkPwd->requireNumbers(2);
    $checkPwd->requireSymbols();
    $passwordOK = $checkPwd->check();
    if ($passwordOK) {
        $result = ['Password OK'];
    } else {
        $result = $checkPwd->getErrors();
    }
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>Register User</title>
    <style>
        label {
            display:inline-block;
            width:125px;
            text-align:right;
            padding-right:2px;