i need some php help!?

Bat

New member
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>
 
You can't put PHP in the attribute of an element. PHP stands for HTML PreProcessor (despite the TLA), which means that PHP is processed before the page is done loading. You can only use JavaScript in this case, and if you want to access the server using JavaScript, read up on using Ajax.
 
Here's a tutorial and creating and reading cookies with PHP:

http://www.w3schools.com/PHP/php_cookies.asp

To underline text just wrap the text in the <u> tag</u>
 
Back
Top