Salve Håkedal wrote:
Maybee my believe in php is a little too big..
When submitting a small string multiple times
with this form, I'd expect $file to build up.
Why does $file contain only the last submit?
<html>
<head>
<title>Silly idea?</title>
</head>
<?
error_reporting(E_ALL);
ini_set('display_errors', '1');
$file .= $_POST['field'];
// The previous statement will generate a Notice about $file not having
// been previously defined
echo "
<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">
<input type=\"text\" name=\"field\">
<input type=\"submit\" value=\"Submit\">
";
echo $file;
?>
</body>
</html>
Try this instead:
<html>
<head>
<title>Good Idea!</title>
</head>
<body>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
session_start();
if (!isset($_SESSION['file'])) $_SESSION['file'] = '';
$_SESSION['file'] .= $_POST['field'] . '<br/>';
echo "
<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">
<input type=\"text\" name=\"field\">
<input type=\"submit\" value=\"Submit\">
";
echo $_SESSION['file'];
?>
</body>
</html>
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :