Welcome Guest, Not a member yet? Register   Sign In
Suppress all PHP errors
#2

[eluser]Michael Wales[/eluser]
Write your code in terms it doesn't trust the user - the user should be able to change anything in your URL and you will gracefully degrade for them:

Example URL: example.com/user/profile/walesmd
Code:
function profile($username = FALSE) {
  if ($username === FALSE) {
    redirect('users/all');
    return;
  }
  $data['user'] = $this->user->get($username);
  $this->load->view('users/profile', $data);
}

Model:
Code:
function get($username = FALSE) {
  if ($username !== FALSE) {
    $username = (str) $username;
    $query = $this->db->get('users', array('username' => $username), 1, 0);
    if ($query->num_rows() === 1) {
      return $query->row_array();
    }
  }
  return FALSE;
}

View file:
Code:
<?php if ($user !== FALSE): ?>
  <?php // Echo out the user's profile information ?>
<?php else: ?>
  <p>We couldn't find a user with that username!</p>
&lt;?php endif; ?&gt;


Messages In This Thread
Suppress all PHP errors - by El Forum - 01-30-2009, 10:00 PM
Suppress all PHP errors - by El Forum - 01-30-2009, 10:57 PM
Suppress all PHP errors - by El Forum - 01-31-2009, 05:25 AM
Suppress all PHP errors - by El Forum - 01-31-2009, 02:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB