function ValidateRegisterForm($post) { if (validateFirstName($post['firstName']) && validateLastName($post['lastName']) && validateEmail($post['email']) && validatePassword($post['password']) && validateConfirmPassword($post['confirmPassword']) && validateGender($post['gender']) && validateContactNumber($post['contactNumber']) && validateAddress($post['address'])) { return true; } else { return false; } }
<input type="password" name="CONFIRMPASSWORD" size="30" id="confirmPasswd" class="validates" onkeyup="passwdValid()" <?php if (!validatePassword($password1, $password2)) { echo $styleInvalid; } ?> /> <span class="formcheck" id="spanPasswd"></span><br /> </fieldset> <fieldset id="fieldYN"> Gender: <input type="radio" name="GENDER" value="male" id="maleRadio" /><label class="noLabel" for="maleRadio">Male </label> <input type="radio" name="GENDER" value="female" id="femaleRadio" /><label class="noLabel" for="femaleRadio">Female </label><?php if (!validateGender($gender)) { echo "*"; } ?> <br /> <label for="mailYes" id="mailList">Subscribe to our mailing list:</label> <input type="checkbox" name="SUBSCRIPTION" value="Yes" id="mailYes" checked /><br /> <label for="comments" class="noLabel">Comments:</label><br /> <textarea id="comments" name="comments" rows="3" cols="55"></textarea> </fieldset> <div class="buttons"> <input type="submit" class="buttons" name="Submit" alt="Submit" value="Submit" id="submit" /> <input type="reset" class="buttons" name="Reset" value="Reset" /> </div>
require_once "php/validation.php"; require_once "php/error.php"; require_once "php/storedprocedures.php"; $newLocation = $_POST['location']; $newEmail = $_POST['email']; $newGender = $_POST['gender']; $newPostsPerPage = intval($_POST['postsperpage'], 10); $newTimeZone = $_POST['timezone']; $errors = array(); if (!validateLocation($newLocation)) { $errors[] = "location=" . ERR::LOCATION_BAD; } if (!validateEmail($newEmail)) { $errors[] = "email=" . ERR::EMAIL_BAD; } if (!validateGender($newGender)) { $errors[] = "gender=" . ERR::SEX_BAD; } if (!validatePostsPerPage($newPostsPerPage)) { $errors[] = "postsperpage=" . ERR::POSTS_PER_PAGE_BAD; } if (!validateTimeZone($newTimeZone)) { $errors[] = "timezone=" . ERR::TIME_ZONE_BAD; } if (count($errors) == 0) { $db = connectToDatabase(); if ($db) { $results = modifyUserDetails($db, $_SESSION['id'], $_SESSION['token'], $newLocation, $newEmail, $newGender, $newPostsPerPage, $newTimeZone); // header("Location: profile.php?error=". $results[SP::ERROR]); switch ($results[SP::ERROR]) { case ERR::TOKEN_EXPIRED: