Welcome Guest, Not a member yet? Register   Sign In
login session help
#1

[eluser]sasori[/eluser]
hi can you help me how to set up the logic for this ? yeah i need code snippets.
i know its easy to do this on native php code LOL
but am having hard time doing this in CI

the practice app that i was building allows the user to register and login
and add a bookmark URL in the db.
but when my user get's logged-in, all the URLs are being pulled out
LOL, that sucks, what if its a real application. once you log-in
you can get other peoples data

here's my controller code

Code:
public function members_area()
  {
    $user = $this->session->userdata('username');
    if($user)
    {
    $data['q'] = $this->member_model->get_urls($user);
    $data['title'] = "Members Area";
    $data['main_content'] = 'includes/member_view';
    $this->load->view('includes/template',$data);
    $this->session->set_flashdata('Problem',"You don't have any URLs lol");
    }
  }

here's the model that pulls the URLs

Code:
public function get_urls($user)
  {
      $this->db->where('username',$user);
      $query = $this->db->get('user');
    if(isset($user) && $query->num_rows != 0)
    {
    $q = $this->db->get('bookmark');
    return $q;
    }
    else
    {
      return false;
    }

  }

and here's the view code

Code:
if($q->num_rows != 0)
    {
    foreach($q->result() as $row)
        {
         echo "<tr>";
         echo "<td>".anchor('site/delete'.$row->bm_URL,$row->bm_URL)."</td>";
         echo "<td>".form_checkbox('delete[]',$row->bm_URL)."</td>";
         echo "</tr>";
         }
    }
    else
    {
      echo $this->session->flashdata('Problem');
    }
#2

[eluser]WebsiteDuck[/eluser]
Code:
$this->db->where('username',$user); //add this
$q = $this->db->get('bookmark');

The reason you are getting all the URLs is because you don't have a "where" before your "get".
#3

[eluser]sasori[/eluser]
daemn,that made me laugh, thanks for the help Sir. it works now Smile




Theme © iAndrew 2016 - Forum software by © MyBB