Jump to content

Archived

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

deaf_jupiter

Passing Vars over URL

Recommended Posts

Hi,

I came up this problem today:
I tried to pass a variable to a script creating a URL like:

article.php?id=25

Unfortunately it appears $id is quite empty. Is there some setting I need to alter?
It used to work in the past (php4 that is).
Also, I don't have great access to the settings so is there also a workaround besides changing the ini file?

Thank you in advance!

Share this post


Link to post
Share on other sites
now the query string is parsed into "SUPERGLOBALS"

The ?GET query string can be accessed with the SuperGlobal $_GET (Array)

eg.

[code]<?php
$id = $_GET["id"];
echo $id;
?>[/code]

This was changed because from earlier versions of PHP for security and performance concerns. POST vars are now stored in $_POST :)
hth..

NOTE: you can also turn on the 'old skool' methods in php.ini

Share this post


Link to post
Share on other sites
register_globals is (rightly) turned off in your PHP.ini file - and should remain that way.

to get the contents of id in the URL, use $_GET['id']

[b]edit:[/b] beat me to it :)

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.