kingnutter Posted May 27, 2009 Share Posted May 27, 2009 Hi everyone, In the CMS I am creating, tracks.php is updateable via edit_track.php Only when a user has updated an entry I want a notification to be echoed at the top of tracks.php saying RECORD UPDATED. I am attempting to use a SESSION thus to no avail. In edit_track.php: <?php session_start(); $_SESSION['updated'] = 'yes'; ?> <html>... and in tracks.php: ...if (isset ($_SESSION['updated'])) { echo 'RECORD UPDATED'; unset($_SESSION['updated']); } Should I perhaps be using POST or GET instead? Thanks, KN Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/ Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 In tracks.php, do you have session_start at the beginning of the script? Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-843617 Share on other sites More sharing options...
grissom Posted May 27, 2009 Share Posted May 27, 2009 I'd also add a bit more code in tracks.php to check that the session variable is SET AND is equal to 'yes'. Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-843622 Share on other sites More sharing options...
JonnoTheDev Posted May 28, 2009 Share Posted May 28, 2009 You only need to use sessions if you need the value to persist through all pages of the site until it is destroyed. If it is just to remember an id for a database update on a single page then it would be much easier using a hidden field containing the value in a form. If you are using it to display a message then a url parameter would be easier i.e. tracks.php?update=true Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-843974 Share on other sites More sharing options...
kingnutter Posted May 28, 2009 Author Share Posted May 28, 2009 Thanks for the suggestion, Neil. I'm already sending a variable 'id' as a url parameter. Is it possible to have more than one in a URL? Also, this modification is intended to include to UPDATE, DELETE and ADDED, so is there a sort of "three way switch" I can use to pass the info to the next page? Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-844353 Share on other sites More sharing options...
JonnoTheDev Posted May 28, 2009 Share Posted May 28, 2009 I'm already sending a variable 'id' as a url parameter. Is it possible to have more than one in a URL? Use as many as you like Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-844499 Share on other sites More sharing options...
kingnutter Posted May 28, 2009 Author Share Posted May 28, 2009 Great. But what would such a URL look like? Would it take the following format... add_track.php?id=$xxx,update=true, add=false, delete=false Or what? Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-844562 Share on other sites More sharing options...
roopurt18 Posted May 28, 2009 Share Posted May 28, 2009 foo.php?id=1&qwerty=hello&hi2u=ohnoes Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-844571 Share on other sites More sharing options...
waynew Posted May 28, 2009 Share Posted May 28, 2009 I'm already sending a variable 'id' as a url parameter. Is it possible to have more than one in a URL? Use as many as you like To a point. Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-844579 Share on other sites More sharing options...
JonnoTheDev Posted May 29, 2009 Share Posted May 29, 2009 To a point Unlinkely your going to exceed 2083 characters Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-844772 Share on other sites More sharing options...
kingnutter Posted June 1, 2009 Author Share Posted June 1, 2009 Works a treat. Thanks everyone. Quote Link to comment https://forums.phpfreaks.com/topic/159928-solved-do-i-need-a-session-here/#findComment-846929 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.