Branden Wagner Posted July 22, 2006 Share Posted July 22, 2006 whats the proper way of making a form action call the the page its on?i usually use $_SERVER['PHP_SELF']is there something i should be using in particular?basically i am making a form, and i have the action set to itself... is there a proper way? or a standard? Quote Link to comment https://forums.phpfreaks.com/topic/15358-proper-self-var/ Share on other sites More sharing options...
JaGeK Posted July 22, 2006 Share Posted July 22, 2006 [quote author=Branden Wagner link=topic=101506.msg401834#msg401834 date=1153609107]whats the proper way of making a form action call the the page its on?i usually use $_SERVER['PHP_SELF'][/quote]I think that's the proper way... ;-) Quote Link to comment https://forums.phpfreaks.com/topic/15358-proper-self-var/#findComment-62218 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Author Share Posted July 23, 2006 what do i use to get variables behind that[code]?p=search[/code]completely intact and just tag it on to the end of the PHP_SELF var$url = $_SERVER['PHP_SELF'] . $vars.... u get the point Quote Link to comment https://forums.phpfreaks.com/topic/15358-proper-self-var/#findComment-62251 Share on other sites More sharing options...
hvle Posted July 23, 2006 Share Posted July 23, 2006 well if you want to retrieve the var passing like this: ?p=searchyou will use $_GET:$action = $_GET['p'];echo $action; // will echo search Quote Link to comment https://forums.phpfreaks.com/topic/15358-proper-self-var/#findComment-62253 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Author Share Posted July 23, 2006 yes but in this particular case i want to preserve the string like that, in the future there will be multiple values passed.i know there is a way to do it, and there is a global var, i just cant seem to find it. Quote Link to comment https://forums.phpfreaks.com/topic/15358-proper-self-var/#findComment-62254 Share on other sites More sharing options...
hvle Posted July 23, 2006 Share Posted July 23, 2006 oh i c,I don't know of a preset variable that can hold that string, there should be one.but until you found it, you can pass all the vars in $_GET to a string:$getvarlist = '';foreach ($_GET as $key=>$val) $getvarlist = $key.'='.urlencode($val).'&';now $getvarlist like this: p=search&keyword=john+20smithyou can pass this to url:header('location: ' . $_SERVER['PHP_SELF'] . '?' . $getvarlist);i'm sure there's a better solution for it. Quote Link to comment https://forums.phpfreaks.com/topic/15358-proper-self-var/#findComment-62258 Share on other sites More sharing options...
Branden Wagner Posted July 23, 2006 Author Share Posted July 23, 2006 found it!!!$_SERVER['QUERY_STRING'] Quote Link to comment https://forums.phpfreaks.com/topic/15358-proper-self-var/#findComment-62259 Share on other sites More sharing options...
hvle Posted July 23, 2006 Share Posted July 23, 2006 lol, i knew there is something for it.i'll have to remember it too. Quote Link to comment https://forums.phpfreaks.com/topic/15358-proper-self-var/#findComment-62261 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.