Ejemplo n.º 1
0
function validateEditPassword($metaData, $con)
{
    foreach ($metaData as $inputData) {
        if (empty($_POST[$inputData['name']]) && $inputData['required'] === true) {
            $error[$inputData['name']] = $inputData['errors']['empty'];
        } else {
            if (!empty($_POST[$inputData['name']])) {
                ${$inputData}['name'] = removeUnnecessaryChars($_POST[$inputData['name']]);
                //Create a variable of the input.
                if (!preg_match($inputData['match'], ${$inputData}['name'])) {
                    $error[$inputData['name']] = $inputData['errors']['match'];
                } else {
                    if (array_key_exists('matchCurrent', $inputData) && checkIfPassDbMatches($con, ${$inputData}['name']) !== true) {
                        //If the key matchcurrent exists, check if the submitted password matches the password in the database.
                        $error[$inputData['name']] = $inputData['errors']['matchCurrent'];
                    } else {
                        if (array_key_exists('matchOther', $inputData) && ${$inputData}['name'] != ${$inputData}['matchOther']) {
                            //If the key matchother exists in the $inputData and it doesn't match the inputfield it has to match, generate an error.
                            $error[$inputData['name']] = $inputData['errors']['matchOther'];
                        }
                    }
                }
            }
        }
    }
    if (empty($error)) {
        $error = [];
        editPassWord($con, $passWord);
    }
    return $error;
}
Ejemplo n.º 2
0
function validateRegOrEditCredInput($metaData, $con)
{
    foreach ($metaData as $inputData) {
        if (empty($_POST[$inputData['name']]) && $inputData['required'] == true) {
            $error[$inputData['name']] = $inputData['errors']['empty'];
        } else {
            if (!empty($_POST[$inputData['name']]) || empty($_POST[$inputData['name']]) && $inputData['required'] == false) {
                // If the inputdata is not empty OR is empty and not required...
                ${$inputData}['name'] = empty($_POST[$inputData['name']]) && $inputData['required'] == false ? "" : removeUnnecessaryChars($_POST[$inputData['name']]);
                // then create a variable of the input named after itself.
                if (!preg_match($inputData['match'], ${$inputData}['name'])) {
                    $error[$inputData['name']] = $inputData['errors']['match'];
                } else {
                    if (array_key_exists('matchOther', $inputData) && ${$inputData}['name'] != ${$inputData}['matchOther']) {
                        // If the key matchother exists in the $inputData and it doesn't match the inputfield it has to match, generate an error.
                        $error[$inputData['name']] = $inputData['errors']['matchOther'];
                    } else {
                        if (strpos($_SERVER['REQUEST_URI'], 'register.php') && $inputData['unique'] == true && checkIfExists($con, $inputData['name'], ${$inputData}['name']) == true) {
                            // If the your location is the register.php AND your inputData has to be unique AND the check if it exists returns true, generate an error.
                            $error[$inputData['name']] = $inputData['errors']['unique'];
                        }
                    }
                }
            }
        }
    }
    if (empty($error) && defineLocation() == true) {
        $error = [];
        createNewUser($passWord, $firstName, $insertion, $lastName, $emailAdress, $phoneNumber, $con);
        // Create a new user!
    } else {
        if (empty($error)) {
            $error = [];
            editExistingCreds($firstName, $insertion, $lastName, $emailAdress, $phoneNumber, $metaData, $con);
            // Edit the user!
        }
    }
    return $error;
}
Ejemplo n.º 3
0
</h1>
		<span class="bold-line"></span>
	</div>
		<?php 
if ($_SESSION['isAdmin'] == true) {
    ?>
 <!-- If the user is an admin, show a search bar. -->
			<form method="get" action="<?php 
    echo htmlspecialchars($_SERVER['REQUEST_URI']);
    ?>
">
				<label for="search">
					Zoeken
				</label>
				<input type="text" class="inputFields" id="search" name="search" value="<?php 
    echo isset($_POST['search']) ? removeUnnecessaryChars($_POST['search']) : '';
    ?>
" placeholder="Zoek"/>
				<input type="submit" class="button" id="searchSubmit" value="Zoek" />
			</form>
		<?php 
}
?>
		<div id="overview">
			<table>
			<?php 
if (empty($appointments) && empty($users)) {
    ?>
	<!-- If there are no appointments nor users, give a message that nothing has been found. -->
				<p>Er zijn geen resultaten gevonden.</p>
			<?php 
Ejemplo n.º 4
0
function startLoginValidation($con)
{
    $emailAdress = removeUnnecessaryChars($_POST["emailAdress"]);
    $passWord = removeUnnecessaryChars($_POST["passWord"]);
    return checkIfLoginInfoIsEmpty($emailAdress, $passWord, $con);
}