public function add_post() { $username = Session::get('username'); if (isset($_POST['submit'])) { if (!$this->_model->add_post($username, $_POST['comment'])) { Session::set_error_output('Unable to add post'); } unset($_POST); Session::redirect('/posts/index'); } }
public function index() { try { Session::clear_error_output(); $this->_view->set_header(); $this->_view->set_footer(); $username = Session::get('username'); if (empty($username)) { Session::redirect(DEFAULT_PAGE); } //print welcome label here. no check needed return $this->_view->render(); } catch (Exception $e) { Session::set_error_output($e->getMessage()); } }
public function create_new_password($new_password) { Session::clear_error_output(); $password = Hash::hash_password($new_password); $email = Session::get('email'); $sql = "UPDATE users SET password=? WHERE email = ? " . "LIMIT 1"; Session::clear_error_output(); $this->_setSql($sql); $this->update_record(array($password, $email)); if ($this->num_rows > 0) { return TRUE; } else { Session::set_error_output('unable to set new password, email address ' . Session::get('email') . ' is not valid'); return FALSE; } }