Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7188053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:58:58+00:00 2026-05-28T18:58:58+00:00

I am trying to pass a segment to a controller. The url is like

  • 0

I am trying to pass a segment to a controller. The url is like base_url/controller/function/seg1. I want to ensure that if the user try to enter the segment in the address bar, the controller would make sure there are not other words to be proceeded except the segment I want to pass.

For example, If the user tries to type base_url/main/function/(change this to other words) in address bar, the controller will filter the segment. I am not sure how to do it and would appreciate if someone can help me out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:58:59+00:00Added an answer on May 28, 2026 at 6:58 pm

    Okay, so the best way to “secure” against such things would be to simply create a session at the time the user logs into your site with two values stored in that session;

    1) Their database primary key id, and
    2) a session item called ‘logged_in’

    At the time that your user would log into your site, you would store those two values like this;

    $this->session->set_userdata('logged_in', true);
    $this->session->set_userdata('user_id', $id);
    

    Where $id is pulled from their user record during authentication.

    Now that you have those in there, the next part would be that, in your controller, you would put an if statement in that checks if the user is logged in, as such;

    function show($id) {
      if($this->session->userdata('logged_in')) {
        $posts = $this->Model_posts->get_user_posts($id);
      }
    }
    

    Now, in your model, you would create a function for pulling the record that you want the user to be able to view based on their user_id. We’ll say user posts for example.

    function get_user_posts($user_id, $post_id) {
       $sql = "SELECT * FROM posts WHERE user_id = ? AND id = ?";
       $binds = array($user_id, $post_id);
       $qry = $this->db->query($sql, $binds);
       $result = array();
    
       while($row = $qry->result_array()) {
         array_push($result, $row);
       }
       return $result;
    }
    

    Now, when a logged in user or visitor tries to access records that don’t belong to them, they will not retrieve any records because the select statement limits what’s returned only to that user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying pass in a url as a paramter to my controller like this:
When trying to pass a table built with HTML in my servlet like that:
im trying to pass back from a user control a list of strings that
So I am trying pass in parameters to my buttonClicked function so that I
im trying to pass two parameters to a function, i being an int value
I am trying to pass a member function within a class to a function
I'm trying to pass one method to another in elisp, and then have that
I'm trying to pass a complex object (that can be serialized, if that helps)
I'm trying to pass an instance of a class between two separate classes, like
I was trying to implement a simple function that can concatenate any number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.