KaiSheng Posted November 7, 2013 Share Posted November 7, 2013 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/ Share on other sites More sharing options...
AbraCadaver Posted November 7, 2013 Share Posted November 7, 2013 If you click: <a href="gameInfo.php?id=<?php echo $_SESSION['id']; ?>"> (notice I changed it) Then on gameinfo.php, you get the id with: $id = $_GET['id']; Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/#findComment-1457312 Share on other sites More sharing options...
KaiSheng Posted November 7, 2013 Author Share Posted November 7, 2013 (edited) 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 November 7, 2013 by KaiSheng Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/#findComment-1457314 Share on other sites More sharing options...
KaiSheng Posted November 7, 2013 Author Share Posted November 7, 2013 Anyone can help? Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/#findComment-1457330 Share on other sites More sharing options...
Rifts Posted November 7, 2013 Share Posted November 7, 2013 can you give more information? Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/#findComment-1457331 Share on other sites More sharing options...
KaiSheng Posted November 7, 2013 Author Share Posted November 7, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/#findComment-1457335 Share on other sites More sharing options...
KaiSheng Posted November 7, 2013 Author Share Posted November 7, 2013 (edited) 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 November 7, 2013 by KaiSheng Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/#findComment-1457340 Share on other sites More sharing options...
Solution Ch0cu3r Posted November 7, 2013 Solution Share Posted November 7, 2013 Post the code that is setting the $_SESSION['id'] variable here. Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/#findComment-1457351 Share on other sites More sharing options...
mac_gyver Posted November 8, 2013 Share Posted November 8, 2013 it should be noted the the OP continued this in another thread and no further action is needed in this thread. Quote Link to comment https://forums.phpfreaks.com/topic/283676-get-and-session-variables/#findComment-1457476 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.