Jump to content

filling an array from html form


mrplatts

Recommended Posts

I need to fill an array with dates from an HTML form.  The user should be able to enter dates, but the number of dates could be different each time.

I tried to write it with the form submitting to itself and then displaying the contents of the array in a box next to the field.  however, I realize that each time that I submit the form,[POST] there is a new array created, not an additional entry into the array, only the most recent addition goes in.

Is there a better way to fill an array from a web form?



I'm learning a lot from reading this forum & am basically learning PHP as I go.  I'm sure my code will need to be seriously re-written when I'm "done"
Link to comment
Share on other sites

I implemented the idea above, it made sense to me...



I wrote:
[code]$excepts = $HTTP_POST_VARS['exceptions'];

if($excepts){
$excepts[] = explode("\n",add_slashes($_POST['exceptions']));
foreach ($excepts as $field => $label)
{
list($xm, $xd, $xy) = explode("-", $label); // seperate the month, date & year
$label = $xy."-".$xm."-".$xd; / reassemble in MySQL format
}
}[/code]

And I got:

Fatal error: Call to undefined function: add_slashes() in /home3/mrplatts/mrplatts-www/sched/cal_setup.html on line 28

I'm not really sure if the way I wrote it puts it back into the same spot on the array. Usually I mess with it until it does what I want.

Rich
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.