}
if (empty($_POST["lastname"])) {
    $databaseflag = false;
    $lastnameErr = "Lastname is required";
} else {
    $lastname = errorcheck($_POST["lastname"]);
    if (!preg_match("/^[a-zA-Z ]*\$/", $Lastname)) {
        $databaseflag = false;
        $lastnameErr = "Only letters and white spaces are allowed";
    }
}
if (empty($_POST["email"])) {
    $databaseflag = false;
    $emailErr = "Email is required";
} else {
    $email = errorcheck($_POST["email"]);
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $databaseflag = false;
        $emailErr = "Invalid email format";
    }
}
if (empty($_POST["password"])) {
    $databaseflag = false;
    $passwordErr = "Password is required";
}
if (empty($_POST["gender"])) {
    $databaseflag = false;
    $genderErr = "Gender is required";
}
$_SESSION["firstnameErr"] = $firstnameErr;
$_SESSION["lastnameErr"] = $lastnameErr;
Пример #2
0
    
        <div id="left-column"><?php 
include 'inc/menu.php';
?>
</div>
        
        <div id="center-column">
            <div class="top-bar">
                    <h1>Mr. Menu - Login</h1>
            </div><br />
            <div id="lista">
            	<?php 
if (!$authorizer->sessionSet()) {
    //logica della pagina (la solita)
    if ($_POST['_check']) {
        if ($form_errors = errorcheck()) {
            form($form_errors);
        } else {
            welcome();
        }
    } else {
        form();
    }
} else {
    die("You are already logged in");
}
function form($errors = '')
{
    if ($errors) {
        $error_text .= '<p class="error">';
        $error_text .= implode('</p><p class="error">', $errors);