batfink1 Posted July 6, 2009 Share Posted July 6, 2009 the below script is my page so far. this all works great and when you click a radio button it adds to the running text list the with the last item clicked at the top along with the date and time. however i would like this info saved in a cookie so when the user closes an reopens the page the same results appear. i would also like the most recent (top line) of the running text list to be underlined any ideas people cheers...code below... <html> <head> <title>Test Sport List</title> </head> <body> <?php $sport_list=''; if (isset($_POST['sports'])) { $sport = $_POST['sports']; $dts = date("G:i:s d/m/y"); if ($_POST['sport_list']) { $sport_list = "<li>$sport $dts" . $_POST['sport_list'] . "</li>"; } else { $sport_list = "<li><u>$sport $dts</li><u />"; } } ?> <form name="test" action="<?php echo($_SERVER['PHP_SELF']); ?>" method="post" > <input type="hidden" name="sport_list" value="<?php echo($sport_list); ?>"> <input type="radio" name="sports" id="01" value="skate" onclick="document.test.submit();" /><label for="01">skateboard</label> <input type="radio" name="sports" id="02" value="football" onclick="document.test.submit();" /><label for="02">football</label> </form> <?php echo($sport_list); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/164995-need-some-php-help/ Share on other sites More sharing options...
blueman378 Posted July 6, 2009 Share Posted July 6, 2009 can we see your attempt at either part of the problem? Link to comment https://forums.phpfreaks.com/topic/164995-need-some-php-help/#findComment-870010 Share on other sites More sharing options...
batfink1 Posted July 6, 2009 Author Share Posted July 6, 2009 ive tryed adding setcookie("sport",$sportlist); but it says the headers have all ready been sent and i'm completly stuck on the underlining bit so any help will be great Link to comment https://forums.phpfreaks.com/topic/164995-need-some-php-help/#findComment-870019 Share on other sites More sharing options...
p2grace Posted July 6, 2009 Share Posted July 6, 2009 Make sure the setting of the cookie is being set before the html of the page has begun displaying... also I don't see a variable called $sportlist, there's a $sport and a $sport_list but not a $sportlist. Link to comment https://forums.phpfreaks.com/topic/164995-need-some-php-help/#findComment-870030 Share on other sites More sharing options...
batfink1 Posted July 6, 2009 Author Share Posted July 6, 2009 Make sure the setting of the cookie is being set before the html of the page has begun displaying... also I don't see a variable called $sportlist, there's a $sport and a $sport_list but not a $sportlist. sorry i forgot the underscore i ment $sport_list Link to comment https://forums.phpfreaks.com/topic/164995-need-some-php-help/#findComment-870035 Share on other sites More sharing options...
p2grace Posted July 6, 2009 Share Posted July 6, 2009 Move your php logic above the <html> tag in your script. That is what's causing the header issue. Link to comment https://forums.phpfreaks.com/topic/164995-need-some-php-help/#findComment-870044 Share on other sites More sharing options...
batfink1 Posted July 6, 2009 Author Share Posted July 6, 2009 cheers for that:) the cookie bit works fine now. you got any idea about getting the latest in the list underlined still cant get that bit Link to comment https://forums.phpfreaks.com/topic/164995-need-some-php-help/#findComment-870047 Share on other sites More sharing options...
p2grace Posted July 6, 2009 Share Posted July 6, 2009 Change this: $sport_list = "<li><u>$sport $dts</li><u />"; To: $sport_list = "<li style='text-decoration: underline;'>$sport $dts</li>"; Link to comment https://forums.phpfreaks.com/topic/164995-need-some-php-help/#findComment-870049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.