Page 1 of 1

Pass an ID into new page.

Posted: Wed Sep 02, 2009 5:14 pm
by synical21
Ive googled how to pass indentification into a new page and other various keywords and not finding much. The case isnt as simple as using $_SESSION as the id isnt the current users. On the page is a table, in this table is various user id's and a link to a new page in every row. The new page will be the process which interacts with the user id of that row.

User ID - Title - Link
User ID - Title - Link
User ID - Title - Link
User ID - Title - Link

isit possible?

Re: Pass an ID into new page.

Posted: Wed Sep 02, 2009 5:55 pm
by AlanG
Anything's possible if you wish hard enough. :)

Best method is to pass the id in as a get variable

(The Link has been replaced with the html code)

USER ID - Title - Link
1 - Tom - <a href="yourscript.php?id=1">Link</a>
2 - Tom - <a href="yourscript.php?id=2">Link</a>
3 - Tom - <a href="yourscript.php?id=3">Link</a>

In the yourscript.php you can catch the id using this code:

Code: Select all

$id = (isset($_GET['id']) && !empty($_GET['id']) && is_numeric($_GET['id'])) ? $_GET['id'] : 0;
If the id is set, not zero and is a number it will assign the number to $id, otherwise it will set it as zero. :)

Re: Pass an ID into new page.

Posted: Wed Sep 02, 2009 6:08 pm
by synical21
Alan G to the rescue! :drunk:

I need to buy one of you from my local store :(

Havnt tested it yet but your replies always work

Re: Pass an ID into new page.

Posted: Wed Sep 02, 2009 6:15 pm
by requinix
synical21 wrote:The case isnt as simple as using $_SESSION as the id isnt the current users.
As long as the current user doesn't change, you can put whatever you want in $_SESSION. Whatever. It doesn't have to be directly related to the current user.

Re: Pass an ID into new page.

Posted: Wed Sep 02, 2009 6:21 pm
by AlanG
synical21 wrote:Alan G to the rescue! :drunk:

I need to buy one of you from my local store :(

Havnt tested it yet but your replies always work
:) Not always... No one knows everything. :) Best of luck with it.

Re: Pass an ID into new page.

Posted: Wed Sep 02, 2009 6:26 pm
by synical21
Just tested works like a charm thanks alan