martin9t9 Posted June 6, 2011 Share Posted June 6, 2011 hey guys im writing some code for my website... it goes like this Page 1 <?php /* this page is sent to page 2 */ $postid = 105; ?> Page 2 <?php session_start(); /* this page redirects to page 3 */ $_SESSION[$postid]='rating'; ?> Page 3 <?php if($_SESSION['$rows['id'] == $rows['id']) echo 'yes'; else echo 'no'; ?> this code is on www.martin9t9.com/announcement once youve signed up join the pakenham network then go to the homepage and click on of the ticks, i wanna make it so you can only press that button once. the part im unsure of is the $_SESSION[$postid] = 'true'; part i dont understand why i can use the variable there. Quote Link to comment https://forums.phpfreaks.com/topic/238545-help-with-sessions-and-variables/ Share on other sites More sharing options...
WebStyles Posted June 6, 2011 Share Posted June 6, 2011 not sure what you want. page 3 does not start with session_start() so you wont be able to access $_SESSION variables. it also has some errors. Quote Link to comment https://forums.phpfreaks.com/topic/238545-help-with-sessions-and-variables/#findComment-1225863 Share on other sites More sharing options...
martin9t9 Posted June 6, 2011 Author Share Posted June 6, 2011 Pretty much all I wanna do is use this code $_SESSION['$variable'] = 'something'; but what's the syntax? I can't seem to beable to use $variable where it is like that. Quote Link to comment https://forums.phpfreaks.com/topic/238545-help-with-sessions-and-variables/#findComment-1225882 Share on other sites More sharing options...
revraz Posted June 6, 2011 Share Posted June 6, 2011 Because you can't. What's wrong with $_SESSION['variable'] ? Look at a Session tutorial, sounds like you are just unsure how they work. Quote Link to comment https://forums.phpfreaks.com/topic/238545-help-with-sessions-and-variables/#findComment-1225891 Share on other sites More sharing options...
martin9t9 Posted June 6, 2011 Author Share Posted June 6, 2011 I can't use that because I want more than one session depending on the variable. What I'm doing is making a website where you can make posts then you can rate them but I only want them to beable to be rated once by that person so I was gonna make a session to make that so. Quote Link to comment https://forums.phpfreaks.com/topic/238545-help-with-sessions-and-variables/#findComment-1225897 Share on other sites More sharing options...
WebStyles Posted June 6, 2011 Share Posted June 6, 2011 if they have to logon to vote/rate then you can use their username in a session variable to track which ones they've voted on. this of course will be reset if they logout and then logon again. better to just store their votes in a database. Quote Link to comment https://forums.phpfreaks.com/topic/238545-help-with-sessions-and-variables/#findComment-1225902 Share on other sites More sharing options...
martin9t9 Posted June 6, 2011 Author Share Posted June 6, 2011 Could you please give me an example of how to do this, I am pretty new to php. Quote Link to comment https://forums.phpfreaks.com/topic/238545-help-with-sessions-and-variables/#findComment-1226142 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.