Forum Moderators: coopster
$info = $_GET[info];
$ic=count($_SESSION);
if (isset($_GET[info]))
{
$ic++;
$_SESSION[$ic] = $info;
}
i am confused as to why it doesnt add to the array, when i go to print_r shows only [1] item in the array over and over?
j.
-- file: thisone.php --
<?php
session_start();
$word=$_POST['word'];
array_push($_SESSION, $word);
print_r ($_SESSION);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<br />
<br />
<br />
<FORM METHOD="POST" ACTION="thisone.php">
Word: <input type="text" name="word">
<input type="SUBMIT" value="Submit">
</FORM>
</body>
</html>
thx.j.
thanks
j.
<?php
session_start();
if(!isset($_SESSION['word'])) $_SESSION['word'] = array();
if(isset($_POST['word']) &&!empty(trim($_POST['word']))
{
$_SESSION['word'][] = $_POST['word'];
}print_r ($_SESSION);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<br />
<br />
<br />
<FORM METHOD="POST" ACTION="thisone.php">
Word: <input type="text" name="word">
<input type="SUBMIT" value="Submit">
</FORM>
</body>
</html>