Example #1
0
function valid($email, $password)
{
    $errors = array();
    if (empty($email) || empty($password)) {
        $errors['empty'] = "Veuillez saisir les deux champs";
    } else {
        if (!emailValid($email)) {
            $errors['email'] = "Compte inexistant";
        } else {
            if (!loginValid($email, $password)) {
                $errors['password'] = "******";
            }
        }
    }
    return $errors;
}
Example #2
0
 if (confirmUser($_SESSION['username'], $_POST['passcurr']) != 0) {
     $alertArr[] = $ALERT['PASS_CURR_WRONG'];
 }
 if ($_POST['pass_1'] != $_POST['pass_2']) {
     $alertArr[] = $ALERT['PASS_DIFF'];
 }
 if (strlen($_POST['pass_field_1']) > 30) {
     $alertArr[] = $ALERT['PASS_TOLONG'];
 }
 if ($_POST['pass_field_1'] && strlen($_POST['pass_field_1']) < 6) {
     $alertArr[] = $ALERT['PASS_TOSHORT'];
 }
 if (strlen($_POST['email']) > 140) {
     $alertArr[] = $ALERT['EMAIL_TOLONG'];
 }
 if ($_POST['email'] && !emailValid($_POST['email'])) {
     $alertArr[] = $ALERT['EMAIL_INVALID'];
 }
 if ($_POST['email'] && emailExist($_POST['email'])) {
     $alertArr[] = $ALERT['EMAIL_TAKEN'];
 }
 if (count($alertArr) == 0) {
     // Add the new account to the database
     // (password has already been encrypted using javascript)
     $_SESSION['reguname'] = $_SESSION['username'];
     $_SESSION['regresult'] = addNewUser($_POST['pass1'], $_POST['email']);
     $_SESSION['registered'] = true;
     $refresh = $HTTP_SERVER_VARS[PHP_SELF];
     exit(include_once HTML_PATH . "html_refresh.php");
     // stop script
 }
Example #3
0
<?php

require_once "../../libs/env.php";
require_once "../../libs/utils.php";
require_once '../../libs/securimage/securimage.php';
$t->assign('captchaHtml', null);
$t->assign('messages', null);
$t->assign('name', "");
$t->assign('email', "");
$t->assign('message', "");
$t->assign('subject', "");
if (isset($_POST['submit'])) {
    $msg = array();
    if (!emailValid($_POST['email'])) {
        array_push($msg, "Email address is not valid.");
    }
    if (!strlen($_POST['message']) > 0) {
        array_push($msg, "You must enter a message.");
    }
    if (!strlen($_POST['subject']) > 0) {
        $_POST['subject'] = 'Feedback on Delphi';
    }
    if (count($msg) <= 0) {
        /* Verify the captcha, but only if everything else is good */
        $securimage = new Securimage();
        if ($securimage->check($_POST['captcha_code']) == false) {
            array_push($msg, "The \"captcha\" text entered was incorrect.<br />Please try again.");
        }
    }
    if (count($msg) > 0) {
        $t->assign('name', cleanFormData($_POST['name']));
<?php

/* includes PHP functions, activates the myAutoloader*/
emailValid("*****@*****.**");
/*Validates user email and ensures the length is 8 to 30 chars*/
function emailValid($email)
{
    if (filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($email) <= 30) {
        echo "evaluated true";
    } else {
        echo "evaluated false";
    }
}
function checkSubmitValues()
{
    // Errors to show if we find any
    $msg = array();
    global $t;
    // reassign vars to user input in case we need to send them back to fix something.
    $t->assign('email', cleanFormData($_POST['email']));
    $t->assign('user', cleanFormData($_POST['user']));
    if (strlen($_POST['pass']) < 6) {
        array_push($msg, "Your password must be at least 6 characters.");
    }
    if (strlen($_POST['pass']) > 25) {
        array_push($msg, "Your password cannot be more than 25 characters.");
    }
    if ($_POST['pass'] != $_POST['pass2']) {
        array_push($msg, "Your retyped password did not match the first typed password.");
    }
    /* Spruce up username, check length */
    if (strlen(stripslashes($_POST['user'])) > 40 || strlen(stripslashes($_POST['user'])) < 3) {
        array_push($msg, "Username must be between 3 and 40 characters.");
    } elseif (!preg_match('|^[a-zA-Z0-9-_]+$|i', $_POST['user'])) {
        array_push($msg, "Username can only contain letters, numbers, hyphens, and underscores");
    } elseif (usernameTaken($_POST['user'])) {
        array_push($msg, "The username \"" . cleanFormData($_POST['user']) . "\"is already taken. Please pick another one.");
    }
    /* Check if email is valid */
    if (!emailValid($_POST['email'])) {
        array_push($msg, "Email address is not valid.");
    }
    if (count($msg) <= 0) {
        /* Verify the captcha, but only if everything else is good */
        $securimage = new Securimage();
        if ($securimage->check($_POST['captcha_code']) == false) {
            array_push($msg, "The \"captcha\" text entered was incorrect.<br />Please try again.");
        }
    }
    if (count($msg) > 0) {
        $t->assign('messages', $msg);
        $t->assign('captchaHtml', Securimage::getCaptchaHtml());
        $t->display('register.tpl');
        die;
    } else {
        return true;
    }
}
Example #6
0
        		нужную нам страницу*/
        header('Location:http://' . $_SERVER['HTTP_HOST'] . '/admin.php?do=reg&active=ok');
        exit;
    }
}
/*Если нажата кнопка на регистрацию,
 начинаем проверку*/
if (isset($_POST['submit'])) {
    //Утюжим пришедшие данные
    if (empty($_POST['login'])) {
        $err[] = 'Поле Логин не может быть пустым';
    }
    if (empty($_POST['email'])) {
        $err[] = 'Поле Email не может быть пустым!';
    } else {
        if (emailValid($_POST['email']) === false) {
            $err[] = 'Не правильно введен E-mail' . "\n";
        }
    }
    if (empty($_POST['pass'])) {
        $err[] = 'Поле Пароль не может быть пустым';
    }
    if (empty($_POST['pass2'])) {
        $err[] = 'Поле подтверждения пароля не может быть пустым';
    }
    if (empty($_POST['key'])) {
        $err[] = 'Поле ключа защиты не может быть пустым!';
    }
    //Проверяем наличие ошибок и выводим пользователю
    if (count($err) > 0) {
        echo showErrorMessage($err);