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 6049637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:35:57+00:00 2026-05-23T07:35:57+00:00

Hello I am new to codeigniter. I am learning this framework by developing a

  • 0

Hello I am new to codeigniter. I am learning this framework by developing a testing application. I am showing user listing and in front of each record an anchor tag to edit that record. That anchor tag looks like

echo(anchor('first/edit_user/'.$value->id,'Edit'));

It redirects the browser to first controller and edit_user function. At edit_user function I load the view of edit like this.

$this->load->view('edit_user',$data);

It loads the view with respect to selected record to edit the record and the url looks like

http://localhost/CodeIgniter/index.php/first/edit_user/9 

Every thing works fine. But when user clicks the update button it again comes to same function. It updates record and then again tries to load the same view but here a problem occurs. Now after updating record it loads the view and url becomes like this

http://localhost/CodeIgniter/index.php/first/edit_user

It creates error as it is not having the id of the selected record. IF i change the load view code of my function like this

          $this->load->view('edit_user/'$this->uri->segment(3)),$data);

It generates an error of edit_user/.php is not defined and some thing like that. Now I want to ask How can I Redirect the user to same edit form telling that his record has been updated? How to load the view of
selected record from function of the controller?

  • 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-23T07:35:57+00:00Added an answer on May 23, 2026 at 7:35 am

    To redirect to the same URL as the current one:

    redirect(current_url());
    

    Otherwise, be specific where you want to redirect.

    $this->load->view(‘edit_user/’$this->uri->segment(3)),$data);

    It generates an error of edit_user/.php is not defined and some thing like that.

    Instead of using specific URL segments, use the parameters passed to your controller and set defaults, as well as handle the possible absence or invalidity of the arguments passed (url segments). Example:

    function edit_user($id = NULL)
    {
        if ( ! $id) // handle error (redirect with message probably)
    
        $user = $this->user_model->get($id);
    
        if ( ! $user) // User not found, handle the error
    
        // If user found, load the view and data
    
    }
    

    Remember that controllers are still just php classes and functions, and accept user input (anything I can type in the address bar) – so never assume anything about what’s in the URL, always respond appropriately if the data you need isn’t there.

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

Sidebar

Related Questions

Hello iam new to GWT framework. I want to persist my domain objects/entities to
Hello im new to programming, im trying to construct my first simple application, im
Hello I am having trouble regarding div reloading when a new record has been
hello im new and learning javascript. I'm trying to make a program of addition
Hello there and Merry Christmas !!! I am new to WPF and I am
Hello can anybody solve this please I'm creating the object in the action class
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello we have an SQL server application running over a low bandwith connection. We
Hello new to PHP and in a bit of a bind. I need to
class Hello @hello = hello def display puts @hello end end h = Hello.new

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.