Welcome Guest, Not a member yet? Register   Sign In
Hide parameter from URL
#1

Hi,
I have a controller that requires the ID of a given table. The ID shows up on the URL but I need that to be hidden.
Is there a way to pass a parameter to the controller but hiding it from the URL?
Please note I'm not passing the variable through a form.

Thanks!
Reply
#2

you mean get the id of an entry in a database?

you can use models ,one for each table to "model data" eg in model

public function getArticle($slug)

{
return $this->asArray()
->where(['slug' => $slug])
->first();

}

from controller i pass in $slug, from what gets returned i can get values across all fields, including id
Reply
#3

(11-16-2020, 03:03 AM)captain-sensible Wrote: you mean get the id of an entry in a database?

you can use models ,one for each table to "model data" eg in model

public function getArticle($slug)

{
return $this->asArray()
    ->where(['slug' => $slug])
    ->first();

}

from controller i pass in $slug, from what gets returned i can get values across all fields, including id

No, what I mean to say is that I already have the ID and I'm passing it to a controller as a parameter. For example the URL will look like "localhost/controller/ID".

I don't want the ID to show on the URL so that users cannot mess around with URLs. Essentially I want to display only "localhost/controller" on the URL
Reply
#4

The way I do it is to use a hidden form input with the id which can be set from the controller etc.;

then use a get post in the controller.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB