include_once '../../../includes/easyparliament/init.php'; $this_page = "userpassword"; $PAGE->page_start(); $PAGE->stripe_start(); if (get_http_var("submitted")) { // Form's been submitted. // Where we'll store any errors that occur... $errors = array(); $email = trim(get_http_var("email")); if ($email == "") { $errors["email"] = "Please enter your email address"; } elseif (!validate_email($email)) { $errors["email"] = "Please enter a valid email address"; } else { $USER = new USER(); $emailexists = $USER->email_exists($email); if (!$emailexists) { $errors["email"] = 'There is no user registered with that email address. If you are subscribed to email alerts, you are not necessarily registered on the website. If you register, you will be able to manage your email alerts, as well as leave annotations.'; } } if (sizeof($errors) > 0) { // Validation errors. Print form again. display_page($errors); } else { // Change the user's password! $password = $USER->change_password($email); if ($password) { $success = $USER->send_password_reminder(); if ($success) { print "<p>A new password has been sent to " . _htmlentities($email) . "</p>\n"; } else {
function check_input($details) { global $THEUSER, $this_page, $who; // This may be a URL that will send the user back to where they were before they // wanted to join. $ret = get_http_var("ret"); $errors = array(); // Check each of the things the user has input. // If there is a problem with any of them, set an entry in the $errors array. // This will then be used to (a) indicate there were errors and (b) display // error messages when we show the form again. // Check first name. if ($details["firstname"] == "") { $errors["firstname"] = "Please enter {$who} first name"; } // They don't need a last name. In case Madonna joins. // Check email address is valid and unique. if ($details["email"] == "") { $errors["email"] = "Please enter {$who} email address"; } elseif (!validate_email($details["email"])) { // validate_email() is in includes/utilities.php $errors["email"] = "Please enter a valid email address"; } else { $USER = new USER(); $id_of_user_with_this_addresss = $USER->email_exists($details["email"]); if ($this_page == "useredit" && get_http_var("u") == "" && $THEUSER->isloggedin()) { // User is updating their own info. // Check no one else has this email. if ($id_of_user_with_this_addresss && $id_of_user_with_this_addresss != $THEUSER->user_id()) { $errors["email"] = "Someone else has already joined with this email address"; } } else { // User is joining. Check no one is already here with this email. if ($this_page == "userjoin" && $id_of_user_with_this_addresss) { $errors["email"] = "There is already a user with this email address"; } } } // Check passwords. if ($this_page == "userjoin") { // Only *must* enter a password if they're joining. if ($details["password"] == "") { $errors["password"] = "******"; } elseif (strlen($details["password"]) < 6) { $errors["password"] = "******"; } if ($details["password2"] == "") { $errors["password2"] = "Please enter {$who} password again"; } if ($details["password"] != "" && $details["password2"] != "" && $details["password"] != $details["password2"]) { $errors["password"] = ucfirst($who) . " passwords did not match. Please try again."; } } else { // Update details pages. if ($details["password"] != "" && strlen($details["password"]) < 6) { $errors["password"] = "******"; } if ($details["password"] != $details["password2"]) { $errors["password"] = ucfirst($who) . " passwords did not match. Please try again."; } } // Check postcode (which is not a compulsory field). if ($details["postcode"] != "" && !validate_postcode($details["postcode"])) { $errors["postcode"] = "Sorry, this isn't a valid Australian postcode."; } // No checking of URL. if ($this_page == "otheruseredit") { // We're editing another user's info. // Could check status here...? } // Send the array of any errors back... return $errors; }