Hide parameter from URL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Hide parameter from URL (/showthread.php?tid=77986) Pages:
1
2
|
Hide parameter from URL - AndreaL - 11-16-2020 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! RE: Hide parameter from URL - captain-sensible - 11-16-2020 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 RE: Hide parameter from URL - AndreaL - 11-16-2020 (11-16-2020, 03:03 AM)captain-sensible Wrote: you mean get the id of an entry in a database? 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 RE: Hide parameter from URL - InsiteFX - 11-16-2020 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. RE: Hide parameter from URL - Corsari - 05-04-2023 kindly to extend the initial question which is the technique to be used to keep the URL params not viewable in the URL? e.g. I need to show and allow to browse a table which is altogether HMTL table in the view showing an entire table of the DB In my case the URL params would be filters on top of the view table with checkboxes dropdowns radios etc etc E.G. one column is users name one column is active/inactive (checkbox), one column is nation (drop down where to select the nationality) one column is male/female (radio) so applying the filters currently, the URL/admin/users/list becomes URL/admin/users/list?page_group1=1&active=0&nation=france&gend=male so back to the initial question. Which is the technique to adopt in CodeIgniter to have the parameters "?page_group1=1&active=0&nation=france&gend=male" to be passed as if in the URL but not printed/shown in the URL? - and possibly, if e.g I click one of the links of the pagination, to be kept set as they are - and how to manage the change of one of the filters thank you for any TIP RE: Hide parameter from URL - HermyC - 05-04-2023 use SESSION? RE: Hide parameter from URL - Corsari - 05-04-2023 That is the classic method I'm asking if in Codeigniter is conceived for some technique that avoids showing the URL query strings Reading the guide I see a set of utilities for the URL and params query but the guide doesn't cover the technique for my question RE: Hide parameter from URL - InsiteFX - 05-04-2023 Is this what your tring to do? stackoverflow -> How to hide query string from url using .htaccess? RE: Hide parameter from URL - Corsari - 05-04-2023 Hello InsiteFX Thank you for your intervention I have seen some apps' codes built on CI an I guessed those query strings are managed internally as properties Is it possible? That is what I mean as "Codeigniter (or PHP MVC framework in general) technique" Or I can turn the question this way, In your development, for the purpose above, do you make use of - some Codeigniter utilities - sessions - htaccess as you linked ? Or more simply your query string is visible and managed as in a classic PHP app (not MVC) Thank you RE: Hide parameter from URL - InsiteFX - 05-05-2023 I actually use both methods, sessions and form hidden fields. |