$firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $password = $_POST['password']; $password_confirm = $_POST['password-confirm']; $email = $_POST['email']; $avatar = $_POST['avatar']; //initialize variables for form validation $success = true; $userTools = new UserTools(); if (empty($email) || empty($firstname) || empty($password) || empty($password_confirm)) { $error .= "Some required fields are missing.<br/> \n\r"; $success = false; } //validate that the form was filled out correctly //check to see if user name already exists if ($userTools->checkEmailExists($email)) { $error .= "That email is already taken.<br/> \n\r"; $success = false; } //check to see if passwords match if ($password != $password_confirm) { $error .= "Passwords do not match.<br/> \n\r"; $success = false; } if ($success) { //prep the data for saving in a new user object $data['first_name'] = $firstname; $data['last_name'] = $lastname; $data['password'] = md5($password); //encrypt the password for storage $data['email'] = $email;
$success = true; $userTools = new UserTools(); if (empty($email) || empty($firstname) || empty($password) || empty($password_confirm) || empty($password_current)) { $error_edit .= "Some required fields are missing.<br/> \n\r"; $success = false; } //validate the current password // echo $current_user->hashedPassword . "<br/>"; // echo $password_current; if (empty($password_current) || md5($password_current) != $current_user->hashedPassword) { $error_edit .= "The entered Password does not match your current password.<br/> \n\r"; $success = false; } //validate that the form was filled out correctly //check to see if user name already exists if (trim($current_user->email) != trim($email) && $userTools->checkEmailExists($email)) { $error_edit .= "That email is already taken.<br/> \n\r"; $success = false; } //check to see if passwords match if (!empty($password) && $password != $password_confirm) { $error_edit .= "Passwords do not match.<br/> \n\r"; $success = false; } if ($success) { //prep the data for saving in a new user object $current_user->firstname = $firstname; $current_user->lastname = $lastname; if (!empty($password)) { $current_user->hashedPassword = md5(trim($password)); }