Jump to content

Archived

This topic is now archived and is closed to further replies.

Branden Wagner

proper self var

Recommended Posts

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?

Share this post


Link to post
Share on other sites
[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... ;-)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
well if you want to retrieve the var passing like this: ?p=search
you will use $_GET:

$action = $_GET['p'];
echo $action; // will echo search


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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+20smith
you can pass this to url:

header('location: ' . $_SERVER['PHP_SELF'] . '?' . $getvarlist);

i'm sure there's a better solution for it.

Share this post


Link to post
Share on other sites
lol, i knew there is something for it.
i'll have to remember it too.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.