public static function login($mobile, $password) { try { $entity_id_array = self::getEntityId($mobile); if ($entity_id_array['success'] == 0) { $errorcode = $entity_id_array['errorcode']; throw new Exception($entity_id_array['data']); } $entity_id = $entity_id_array['data']; $password_true_array = self::getCustomerColumn($entity_id, 'password_hash', 1); if ($password_true_array['success'] == 0) { $errorcode = $password_true_array['errorcode']; throw new Exception($password_true_array['data']); } $password_true = $password_true_array['password_hash']; $success = validateHash($password, $password_true); if ($success == 0) { $data = 'User or Password Error'; $errorcode = 10042; throw new Exception('User or Password Error'); } else { $data = 'Login Success'; $errorcode = 0; } return array('data' => $data, "success" => $success, "errorcode" => $errorcode); } catch (Exception $e) { return array('data' => $e->getMessage(), "success" => 0, "errorcode" => $errorcode); } }
function validateDelete($post) { // Create an empty array to hold the error messages. $arrErrors = array(); // Each time there's an error, add an error message to the error array. if (!validateHash($post)) { $arrErrors[] = 'The security hash does not match the one in our records. Please try again.'; } if ($post['teacher'] == '' || !is_numeric($post['teacher'])) { $arrErrors[] = 'A valid teacher is required.'; } if ($post['time'] == '') { $arrErrors[] = 'A valid time is required.'; } if (!validateUser($post)) { $arrErrors[] = 'You may not delete appointments for another user.'; } return $arrErrors; }