Using Codeigniter + Bonfire framework I can pass variables in my URL. This all works great with GET function like so:
in my view file I get ID of my user and on click pass it to controller again:
<a href="/my_team/index/<?php echo $user->member->id; ?>">Something</a>
controller then receives ID:
public function index($id = null) {
//do stuff with that id...
}
URL looks like this:
http://mysite/my_team/index/26
And everything on that page knows user has ID of 26 and display information correctly.
Problem is if I manually remove that number from the URL so it looks like this:
http://mysite/my_team/index/
and leave the index in the URL I now get a whole bunch of errors because the site can't get the ID from URL. How can I avoid this? Maybe hide the index
public function from the URL using .htacces or something?
Like @CBroe said in his comment. Something like this:
public function index($id = null) {
if(is_null($id)) {
// redirect to custom error page
}
//do stuff with that id...
}