Esempio n. 1
0
function login()
{
    if (checkUserNameExist($_POST["usernameLogin"], $_POST["passwordLogin"])) {
        checkAdmin($_POST["usernameLogin"]);
        $_SESSION["name"] = $_POST["usernameLogin"];
        $_SESSION["password"] = $_POST["passwordLogin"];
        $_SESSION["login"] = true;
        $version = "private";
        return $version;
    } else {
        errorAlert("The password is incurrect or the user name does not exist!");
    }
}
function validationCheck()
{
    global $link;
    if ($_POST["name"] == "username") {
        if (empty($_POST["value"])) {
            echo "The user name cannot be empty!";
        } else {
            if (strstr($_POST["value"], " ")) {
                echo "The user name cannot contain white space!";
            } else {
                if (checkUserNameExist($_POST["value"])) {
                    echo "This user name already exists!";
                }
            }
        }
    } else {
        if ($_POST["name"] == "password" || $_POST["name"] == "passwordCheak") {
            if (empty($_POST["valueA"])) {
                echo "The password cannot be empty!";
            } else {
                if ($_POST["valueA"] != $_POST["valueB"]) {
                    echo "Entered passwords does not match!";
                } else {
                    if (strstr($_POST["valueA"], ' ')) {
                        echo "The password cannot contain white space!";
                    }
                }
            }
        } else {
            if ($_POST["name"] == "email") {
                if (empty($_POST["value"])) {
                    echo "The email address cannot be empty!";
                } else {
                    if (!strstr($_POST["value"], "@")) {
                        echo "The email address is not correct!";
                    }
                }
            } else {
                if ($_POST["name"] == "city") {
                    if (empty($_POST["value"])) {
                        echo "The city cannot be empty!";
                    }
                } else {
                    if ($_POST["name"] == "usernameLogin") {
                        if (empty($_POST["value"])) {
                            echo "The user name cannot be empty!";
                        } else {
                            if (strstr($_POST["value"], " ")) {
                                echo "The user name cannot contain white space!";
                            }
                        }
                    } else {
                        if ($_POST["name"] == "passwordLogin") {
                            if (empty($_POST["value"])) {
                                echo "The password cannot be empty!";
                            } else {
                                if (strstr($_POST["value"], " ")) {
                                    echo "The password cannot contain white space!";
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}