Reply to Re: Php Form and Array

Your name:

Reply:


Posted by Nico on 12/05/06 12:13

In article <45755cfb$0$334$e4fe514c@news.xs4all.nl>,
Erwin Moller
<since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote:

> Nico wrote:
>
> > Dear all,
> >
> > I created the following php form.
> >
> > <FORM METHOD="POST" ACTION="prova.php">
> > <b>Combination</b><br><br>
> > Element 1: <INPUT NAME="el1" TYPE="TEXT">
> > <BR>
> > Element 2: <INPUT NAME="el2" TYPE="TEXT">
> > <br>
> > <INPUT TYPE="SUBMIT" VALUE"Submit">
> > </FORM>
> > <br>
> > Combination<br><br>
> >
> > <?php
> > $combination[] = ($_REQUEST["el1"].$_REQUEST["el2"]);
> > print_r($combination);
> > $combinations[] = $combination;
> > print_r($combinations);
> > ?>
> >
> > When I fill the two text fields of the form in the browser, the inserted
> > text is included in the array $combination and then $combination is
> > included in the array $combinations.
> > When I reload the page, I fill again the two text fields and the new
> > inserted text overwrites the old inserted text. This is a problem.
> > I'd like that the array "combinations" includes both the old inserted
> > text and the new inserted text, but I don't know how to do this.
> > Can you help me please?
> > Many thanks.
> >
> > Best,
> > Nico
>
> Hi Nico,
>
> The problem lies in the fact that you expect your array to exist next time
> you call the page.
> This is NOT the case.
> PHP is invoked per request, and all variables are initialized fresh each
> invocation. PHP does NOT remember what you did in your last script.
>
> If you want PHP to remember values from one invocation to the next, use
> sessions.
> Learn more about them here:
> http://nl3.php.net/manual/en/ref.session.php
>
> Regards,
> Erwin Moller

Many thanks. I'll try to use sessions.
Nico

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация