codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

Header Location with variable


By : , Category : codeigniter

codeigniter provides redirect, like:

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

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:

header("Location:inventory_issue_view.php?filterer_client_name=$clientId");

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

    if($result){
        echo 'location:edit.php?id=' . $id; 
        exit; 
        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.

Cheers

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

Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .