PHPMine
<? if(PHP > $Expectations) echo $Results ?>
by Angel S. Moreno
UNDER SOME SERIOUS CONSTRUCTION LINKS MAY NOT WORK
Asked 2009-07-03 02:49:55 by Bat
hey i have these 2 pages
process.php
PHP Code:
<?php
$sport = $_POST['sports'];
$date = date("d/m/y");
$time = date("G:i:s");
$data_1 = "$sport $time $date";
setcookie("cookie",$data_1);
header("location: code.php");
?>
and code.php
PHP Code:
<form name="test" action="process.php" method="post" >
<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 "<u>";
echo $_COOKIE['cookie'];
echo "<u />";
?>
so yeah when you click on one of the radio buttons you see
football 23:09:01 01/07/09
but i want a running text list showing the most recent buttons and times you clicked on it not just once. so it would be like
skate 23:53:35 01/07/09
skate 23:49:11 01/07/09
football 23:09:01 01/07/09
any ideas?
Anwered 2009-07-03 04:12:36 by rbjolly
Try the following (all one page):
<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>$sport $dts</li>";
}
}
?>
<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>
<ul>
<?php echo($sport_list); ?>
</ul>
</body>
</html>
Anwered 2009-07-03 02:54:54 by Lost One
You need to set an array into the cookie and set $data = "$_COOKIE['cookie'] <br> <new data here> " For this to take effect...I don't know why you use cookies, since they're obsolete and ANNOYING.. You could better use sessions since PHP Is easy with them, cookies used to be useful when you had to put a server session with them.. But now it's automatically:). And oh yes, databases have more use
Questions and answers provided by the Yahoo Answers Community.