rickyj Posted August 8, 2007 Share Posted August 8, 2007 is there a way to redirect www.example/this.php to www.example/this.php?a=1&b=2 I have tried using: if ($_SERVER['PHP_SELF'] == "/this.php") {header( 'Location: http://www.example/this.php?a=1&b=2' );} but this results in a loop, any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/ Share on other sites More sharing options...
teng84 Posted August 8, 2007 Share Posted August 8, 2007 yes you can but it will terminate the loop once it see the header Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/#findComment-318920 Share on other sites More sharing options...
rickyj Posted August 8, 2007 Author Share Posted August 8, 2007 I need it to go to the second page, and then display the contense, its just looping at the moment Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/#findComment-318922 Share on other sites More sharing options...
clanstyles Posted August 8, 2007 Share Posted August 8, 2007 what if you did this if(!isset($_GET['a'] || isset($_GET['a']) { header("Location: page.php?a=1&b=2"); } Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/#findComment-318923 Share on other sites More sharing options...
rickyj Posted August 8, 2007 Author Share Posted August 8, 2007 The problem is, I really dont want to use isset and then get (I cant trust users input so do a lot of stipping of characters). I was initially using isset, and then relised the security flaw Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/#findComment-318928 Share on other sites More sharing options...
teng84 Posted August 8, 2007 Share Posted August 8, 2007 show your code Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/#findComment-318940 Share on other sites More sharing options...
rickyj Posted August 9, 2007 Author Share Posted August 9, 2007 Sorry, cant do that, but I can give examples (as the one above) Im bassically asking it there is a way of grabing the full url, since $_SERVER['PHP_SELF'] only grabs "/this.php" from www.example.come/this.php?other=things&more=1 If I could grab the full url I would be able to show that 'other' and 'more' are or are not set without using isset, or get. I dont like using isset($_GET['a'] ) since if the user manipulates the a variable to "a = ']) && more code //", this is unsafe! Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/#findComment-319177 Share on other sites More sharing options...
JJohnsenDK Posted August 9, 2007 Share Posted August 9, 2007 use: $_SERVER['HTTP_REFERER'] Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/#findComment-319181 Share on other sites More sharing options...
rickyj Posted August 9, 2007 Author Share Posted August 9, 2007 Referer is not used by all browsers (and can easily be faked) Quote Link to comment https://forums.phpfreaks.com/topic/63979-redirect-thisphp-to-thisphpa1b2/#findComment-319201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.