View Single Post
  #3 (permalink)  
Old 11-24-2006, 09:39 PM
Langer Langer is offline
Rookie
 
Join Date: Dec 2005
Posts: 5
Langer is on a distinguished road
You need to add your array to a session variable or some other permanent storage system, because PHP is without state. Additionally, you aren't really cuing the array to expand on post.

<?
session_start();
if(!isset($_SESSION['dAta'])) {
$_SESSION['dAta'] = array("961204","961205","961206");
}

if(isset($_POST['submit'])) {
$arr = $_SESSION['data'];
$arr[] = $_POST['field1'];
$_SESSION['dAta'] = $arr;
print_r($_SESSION['dAta'];
}
?>

<form method="post">
<input id="field1" name="field1" type="text" size="80" value="<? echo $_POST['field1']; ?>" />
<input type="submit" id="submit" name="submit" value="ENTER" />
</form>

Anyplace you want to use the session variable, make sure you have session_start() at the top of that page.

Reply With Quote