Jump to content


Photo

proper self var


  • Please log in to reply
7 replies to this topic

#1 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 22 July 2006 - 10:58 PM

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?


#2 JaGeK

JaGeK
  • Members
  • PipPip
  • Member
  • 20 posts
  • LocationNRW, Germany

Posted 22 July 2006 - 11:02 PM

whats the proper way of making a form action call the the page its on?

i usually use $_SERVER['PHP_SELF']


I think that's the proper way... ;-)

#3 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 01:18 AM

what do i use to get variables behind that

?p=search

completely intact and just tag it on to the end of the PHP_SELF var

$url = $_SERVER['PHP_SELF'] . $vars.... u get the point

#4 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 23 July 2006 - 01:23 AM

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



Life's too short for arguing.

#5 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 01:25 AM

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.

#6 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 23 July 2006 - 01:33 AM

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.
Life's too short for arguing.

#7 Branden Wagner

Branden Wagner
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts

Posted 23 July 2006 - 01:36 AM

found it!!!

$_SERVER['QUERY_STRING']

#8 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 23 July 2006 - 01:40 AM

lol, i knew there is something for it.
i'll have to remember it too.
Life's too short for arguing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users