redirect Header function fails with query string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tcl4p
Forum Newbie
Posts: 15
Joined: Mon Apr 02, 2007 9:28 am

redirect Header function fails with query string

Post by tcl4p »

I'm trying to use the php header function to redirect the current page back to itself and use a query string to pass parameters back to the page. While the redirect works, what happens is the URL that appears is the original URL, with the original query string. Here is the code I'm using for the redirect.

header( "Location: addtemplatetask.php?func=Reset&ID=".$InitialTemplateID);

Any help would be appreciated.

Tom
lshaw
Forum Commoner
Posts: 69
Joined: Mon Apr 20, 2009 3:40 pm
Location: United Kingdom

Re: redirect Header function fails with query string

Post by lshaw »

Have you tried with the variable in the "", because that seems to work for me

Like this:

Code: Select all

 
header( "Location: addtemplatetask.php?func=Reset&ID=$InitialTemplateID");
 
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: redirect Header function fails with query string

Post by AbraCadaver »

tcl4p wrote:I'm trying to use the php header function to redirect the current page back to itself and use a query string to pass parameters back to the page. While the redirect works, what happens is the URL that appears is the original URL, with the original query string. Here is the code I'm using for the redirect.

header( "Location: addtemplatetask.php?func=Reset&ID=".$InitialTemplateID);

Any help would be appreciated.

Tom
It's not really redirecting:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', '1');
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply