Header Location with variable

codeigniter provides redirect, like:

redirect( base_url() . 'action/task/' . $this->index() );

Header returns type of void. You can not expect $error to be anything besides null.

If you are getting a 500 error, it is caused by something else (syntax error?).

How do you get the id of the client? From a query or a form? Hovewer, try:


where $clientId is a variable containing the number.

Try using a session variable. In your first script add

session_start(); to the top of the page.

and to the top of every other page which needs to use a session variable.

you can then set things like $_SESSION['username']. These will be avaiable to every script in the same session, e.g. until the user closes their browser.

the benefit of this over using $_GET is that it's transparent to the browser, and therefore more secure.

If you want me to post more info about this (or anyone else for that matter), I'd be happy to do so.

concatenation with the string looks correct to me.

Are you sure your DB record is correctly updated? If you pass the correct $id to this method it should exists in the redirection header.

I suggest you to reproduce the eventuality where you don't have a value for $id in the new location and do some debug, for example:

public function .....
    echo "The ID is " . $id;

    // the update code here

        echo 'location:edit.php?id=' . $id; 
        header('location:edit.php?id=' . $id);  

    die('result not valid');

Check if the printed $id values are the same, are the expected and if the record was really updated. You should not see the string 'result not valid' as the code exit before.

This is not best practice of testing but should help you understand what is happening.


PS. When you say 'All I get in the browser is ' do you mean you've been redirected to that page, right?


Message :
Login to Add Your Comments .
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .