473,385 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Php Form and Array

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
Dec 5 '06 #1
2 1758
no
On Tue, 05 Dec 2006 11:53:21 +0100, Nico <no*****@noemail.comwrote:
>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.
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*****@noemail.comwrote:
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.

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
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...
7
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>...
6
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...
11
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...
9
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...
2
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,...
26
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...
1
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...
5
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...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.