RE: [PHP] check form - save arrays in hidden fields?
| From: | Tim Ward | Date: | Tue, 26 Mar 2002 14:51:15 +0000 |
| Subject: | RE: [PHP] check form - save arrays in hidden fields? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-90188@lists.php.net to get a copy of this message | ||
Why in a scalar? Why not pass the array through, i.e.
Foreach($test as $element)
{ echo("<input type='hidden' name='test[]'
value='$element'>");
}
Tim Ward
Internet Chess www.chessish.com <http://www.chessish.com>
----------
From: Fabian Krumbholz - 2k web solutions
[SMTP:krumbholz@2k-web.de]
Sent: 26 March 2002 09:31
To: PHP Mailingliste
Subject: [PHP] check form - save arrays in hidden fields?
I have a contact form (form.php). I check the submitted data with
the
same php file.
If the e-mail adress is not valid I ask the user for a valid e-mail
adress.
Therefor I create a new form with the field e-mail. The valid date
name,
adress, ...
I put into hidden fields, so they don't get lost.
This works fine until I integreate a file upload into my form.
The file data stored in the $_FILES array get lost, when I submit
the
form the second time (when the e-mail adress isn't valid).
The same problem occours when I integrate a list box where it is
possible to
choose more then one item:
<select name="test[]" size="3" multiple>
<option value="test1"> test1</option>
<option value="test2"> test2</option>
<option value="test3"> test3</option>
</select>
Is there an easy way (in PHP 4.1.2) to store arrays like scalar
variables in
hidden fields, without using a database or transforming the array
data
into a string?
Thanks,
Fabian Krumbholz
www.2k-web.de