Jump to content

GET and SESSION variables


KaiSheng
Go to solution Solved by Ch0cu3r,

Recommended Posts

Hi, 

on the 1st page

i echo the session id to the 2nd page url

This is the code. <a href="gameInfo.php?id=<?php echo '' . '(' . $_SESSION['id'] . ')'; ?>">

 

on the 2nd page, i try to get the session id to appear to be something like ..gameinfo.php?id=(5).php on the page

with this code

 $id = $_GET[($_SESSION["id"])];

however it only shows up the first id of the user in the database.

I changed account to a different ID user, it still shows up the same result.

is there anything wrong with my quotes or something?

help please thanks!!!

Link to comment
Share on other sites

thanks for the fast reply, that works well.

but the result i want to achieve is for example

in database

userid 1 = john, so when john clicks on gameInfo.php, it will show ..gameInfo.php?id=1

userid 2 = mary, so when mary clicks on gameInfo.php, it will show ..gameInfo.php?id=2

 

that's the part i can't get it ):

 

 

--edit--

 

and also, they can only access the page after they have logged in.

Edited by KaiSheng
Link to comment
Share on other sites

what i want to achieve is that

 

when a user login, he can see a page called gameInfo.php

when he clicks onto that gameInfo.php, the link will show localhost/../gameInfo.php?id=1, if his user id is 1 in the database.

if another user login, if the person user id in database is 2, the page will show localhost/../gameInfo.php?id = 2.

that's what i meant.

 

I got the id to show up on the page already.

But however, no matter which account i log into, it will still show the page localhost/../gameInfo.php?id=1 

i do not know what is the mistake.

I am trying to get the session id to pass through and appear on the link of the page.

Link to comment
Share on other sites

I just found out, when i print S_SESSION['id]; 

the id is always 5.

it doesn't change no matter which account i log into.

Is this a simpler to understand?

I have a session_start()

i do not know why is my session always the same.

help??

Edited by KaiSheng
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.