473,320 Members | 1,724 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,320 software developers and data experts.

Is there any INPUT type that is stored in an array on PHP?

I want to show the user a list of emails and the user must have the
ability to select which ones he wants. Multiple selections must be
allowed. Any way I can do this? In PHP I want to do:

foreach ($_POST['contacts'] as $contact) {
// code...
}

But using Checkboxes doesn't work, I've tried putting them with the
same name but all that appears is a string of the LAST selected
checkbox :S. Help?

Sep 16 '07 #1
5 1131
..oO(RageARC)
>I want to show the user a list of emails and the user must have the
ability to select which ones he wants. Multiple selections must be
allowed. Any way I can do this? In PHP I want to do:

foreach ($_POST['contacts'] as $contact) {
// code...
}

But using Checkboxes doesn't work, I've tried putting them with the
same name but all that appears is a string of the LAST selected
checkbox :S. Help?
Append [] to the names of the checkboxes, e.g.

<input type="checkbox" name="foo[]" value="42">

Then $_POST['foo'] will be an array.

Micha
Sep 16 '07 #2
Thanks Micha :D Didn't know that!

Sep 16 '07 #3
But using Checkboxes doesn't work, I've tried putting them with the
same name but all that appears is a string of the LAST selected
checkbox :S. Help?
I think you need check boxes here. html allow you to create many check
connected with the same name.

<input type="checkbox" name="options[1]" value="1" />Value 1
<input type="checkbox" name="options[2]" value="2" />Value 2
<input type="checkbox" name="options[4]" value="4" />Value 4
the submitted ones should appear as an $_POST array:
[options] =Array
(
[1] =1
[4] =4
)

Sep 16 '07 #4
Thanks guys, it really worked :).

Sep 16 '07 #5
RageARC wrote:
I want to show the user a list of emails and the user must have the
ability to select which ones he wants. Multiple selections must be
allowed. Any way I can do this? In PHP I want to do:

foreach ($_POST['contacts'] as $contact) {
// code...
}

But using Checkboxes doesn't work, I've tried putting them with the
same name but all that appears is a string of the LAST selected
checkbox :S. Help?
Just remember - don't put the email address itself in your form - use
id's, etc. instead. And validate your data.

Spammers just love when you put the email address in a form field. And
they'll love you, also, right up to the time your site gets shut down.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 16 '07 #6

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

Similar topics

7
by: arkobose | last post by:
hey everyone! i have this little problem. consider the following declaration: char *array = {"wilson", "string of any size", "etc", "input"}; this is a common data structure used to store...
116
by: dmoran21 | last post by:
Hi All, I am working on a program to take input from a txt file, do some calculations, and then output the results to another txt file. The program that I've written compiles fine for me, however,...
11
by: arnuld | last post by:
C takes input character by character. I did not find any Standard Library function that can take a word as input. So I want to write one of my own to be used with "Self Referential Structures" of...
0
by: htenay | last post by:
I need to be able to define an array in Java and pass it on to SQL stored procedure. I am new to store proc and found a lot of helpful tutorials on Google but found none that passes parameter of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.