how to keep all values in URL when submitting from a form

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
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

how to keep all values in URL when submitting from a form

Post by deejay »

Hi

What I am trying to do is be able to keep all details that are in the URL after submitting from a form. i am using $PHP_SELF and all details after .php? seem to get lost. Have also looked at using

Code: Select all

$PHP_SELF
$_SERVERї'HTTP_HOST']
$_GETї'URI']
$_SERVER
and i dont think they do what i want them to. Any ideas?
RTT
Forum Commoner
Posts: 38
Joined: Thu Jul 17, 2003 10:22 am
Location: Wolverhampton, UK
Contact:

Post by RTT »

Set your form method to "GET" rather than "POST".

Code: Select all

<form name="formname" action="" method="GET">
Hope this helps!
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

$_SERVER["QUERY_STRING"]
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Post by deejay »

thanks,

i don't suppose you know a good resource website where it lists all Super globals and this sort of stuff, i seem to find http://www.php.net difficult to locate what i need to find out.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

I actually normally just use a phpinfo(); page. Down at the bottom almost all of the SERVER/_ENV variables are echoed out and normally I can tell which one I want from the current value. (Of course QUERY_STRING is an exception as its blank on a phpinfo page, but I knew roughly what I was looking for name-wise....)
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Post by deejay »

actually i found that $_SERVER["QUERY_STRING"] returned

Code: Select all

res://C:\WINDOWS\System32\shdoclc.dll/http_404.htm#https://www1.securesiteserver.co.uk/cctvcity/MonitoringStation/user_id=95&cam=camera2
whereas i just want the info after # .

Thanks
RTT
Forum Commoner
Posts: 38
Joined: Thu Jul 17, 2003 10:22 am
Location: Wolverhampton, UK
Contact:

Post by RTT »

deejay wrote:actually i found that $_SERVER["QUERY_STRING"] returned

Code: Select all

res://C:\WINDOWS\System32\shdoclc.dll/http_404.htm#https://www1.securesiteserver.co.uk/cctvcity/MonitoringStation/user_id=95&cam=camera2
whereas i just want the info after # .

Thanks
Which is why I suggested changing your form method to GET rather than POST :wink:
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Post by deejay »

RTT

it didn't work, although I'm not sure quite why as I agree it should sort it.

anyhow just worked out you can get a list of $_SERVER commands by using
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
think i should be able to sort it now.

Thanks all
Post Reply