Re: How to make a form in php accepting indefinite inputs?
From: Ken Robinson (kenrbnsn_at_rbnsn.com)
Date: 01/25/05
- Next message: adomas.paltanavicius_at_gmail.com: "Re: Maybe easy - securing php files containing DB access passwords etc."
- Previous message: Tom: "Re: How to make a form in php accepting indefinite inputs?"
- In reply to: Ge: "Re: How to make a form in php accepting indefinite inputs?"
- Next in thread: NC: "Re: How to make a form in php accepting indefinite inputs?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Jan 2005 09:30:00 -0800
Ge wrote:
> Thanks for the suggestion. I see the point is use database to store
> the list. But is there any way that I can store and pass along the
list
> without going into the database first?
>
> Yes, a portion of the list will eventually go into the database, but
at
> this stage, I perfer not if I can...
Try this modification of the above code:
<?php
session_start();
$tmp = (isset($_SESSION['tmp']))?$_SESSION['tmp']:array();
if (isset($_POST['action'])) {
// data is added onto the $tmp array whichever button is
pressed
if ($_POST['data'] != '' )$tmp[] =
htmlentities(stripslashes($_POST['data']));
if ($_POST['action'] == "done") {
// clean_data($tmp);
// insert_into_database($tmp);
echo 'The final list of data entered is:<br>'."\n";
for ($i=0;$i<count($tmp);$i++)
echo 'Data: ' . $tmp[$i] . "<br>\n";
unset($_SESSION['tmp']);
exit();
}
$_SESSION['tmp'] = $tmp;
}
for ($i=0;$i<count($tmp);$i++)
echo 'Data: ' . $tmp[$i] . "<br>\n";
?>
<form style="margin-top:0;padding-top:0" action="<? echo
$_SERVER['PHP_SELF'] ?>" method="post">
<label for="data">Data:</label><input type="text" name="data" id="data"
value="" />
<input type="submit" name="action" value="add" /> <input
type="submit" name="action" value="done" />
</form>
Ken (posting from Google Groups Beta which unindents code :-( )
- Next message: adomas.paltanavicius_at_gmail.com: "Re: Maybe easy - securing php files containing DB access passwords etc."
- Previous message: Tom: "Re: How to make a form in php accepting indefinite inputs?"
- In reply to: Ge: "Re: How to make a form in php accepting indefinite inputs?"
- Next in thread: NC: "Re: How to make a form in php accepting indefinite inputs?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]