473,770 Members | 6,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Php Form and Array

Dear all,

I created the following php form.

<FORM METHOD="POST" ACTION="prova.p hp">
<b>Combinatio n</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($combin ation);
$combinations[] = $combination;
print_r($combin ations);
?>

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 "combinatio ns" 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
Dec 5 '06 #1
2 1785
no
On Tue, 05 Dec 2006 11:53:21 +0100, Nico <no*****@noemai l.comwrote:
>Dear all,

I created the following php form.

<FORM METHOD="POST" ACTION="prova.p hp">
<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($combin ation);
$combinations[] = $combination;
print_r($combin ations);
?>

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 "combinatio ns" 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.
Hi Nico

Sounds like you are trying ot make the data persist between page
refreshes. The best way to handle this is to use 'sessions' and make
$combinations into a session variable like $_SESSION['combinations'][]
Just start your PHP code with session_start() ; and then manipulate
your array :o)

Chris R.
Dec 5 '06 #2
In article <a1************ *************** *****@4ax.com>, no@emails.thx
wrote:
On Tue, 05 Dec 2006 11:53:21 +0100, Nico <no*****@noemai l.comwrote:
Dear all,

I created the following php form.

<FORM METHOD="POST" ACTION="prova.p hp">
<b>Combinatio n</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($combin ation);
$combinations[] = $combination;
print_r($combin ations);
?>

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 "combinatio ns" 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.

Hi Nico

Sounds like you are trying ot make the data persist between page
refreshes. The best way to handle this is to use 'sessions' and make
$combinations into a session variable like $_SESSION['combinations'][]
Just start your PHP code with session_start() ; and then manipulate
your array :o)

Chris R.
Many thanks. I'll try to use sessions.
Nico
Dec 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2949
by: JC | last post by:
How do I extract data from a form into the main form for processing? For instance, I have several image files in a form called images(images.frm), indexed from 0 to 99, and I want to import these into a variable array in my main form, main (form1.frm). How do I code a control to get these images into an array in my main form from the images.frm? TIA
7
3615
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
6
2746
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is called "form1", and I have selects called "PORTA", "PORTB" ... etc...
11
12801
by: Ahmet AKGUN | last post by:
Hi; is it possible to open one form in .net platform that we have its name in string ? I have string sFormName = "frmCustomer"; and I must automatically open Customer form. or is it possible to get one referance of an item on form ?
9
1739
by: JW | last post by:
Dear NG, Still working on my .NET CF C# forms application ... I have an array of forms that I wish to display in array order, and thus have created a loop to run through them. Due to functional and speed reasons (this app. will be deployed to a PocketPC) I want to merely Hide() each form when the user is finished with it, rather than allow it to Close(). In this way the user can "back" button their way back to each previous form...
2
7053
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
26
2815
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when they press next the form generates "How old are you?" 5 times on the page. The customer will answer all 5 questions then press next. Finally, all the local variables get dynamically created and written to a database. I have already taken care of...
1
2825
by: Muchach | last post by:
Hello, Ok so what I've got going on is a form that is populated by pulling info from database then using php do{} to create elements in form. I have a text box in each table row for the user to enter input. I need to take this user input and put it back into the database. What would be the best method to do this. I can't use a normal post because the name of the text box is the same for each table row. I've heard that posting the...
5
3311
by: Neil | last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com... Question for you. I'm doing something similar, only, instead of opening the forms all at once, I'm opening them as needed. I have a main form with multiple records; and then I have a pop-up form that the user opens with button. The pop-up form contains one record relating to the current record in the main form (but...
3
4846
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function pointers (delegates). I assume I need to use the array< T keyword to allocate an array of delegates, and then initialize the array by setting each array element to the pointers (handles) of the functions I'll be invoking. I've been trying to...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10231
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.