PHP survey form and checkbox ("array")

Hi!

I am creating an online PHP survey form.


The problem is:
I have a checkbox to ask clients to make a final confirmation of their input. Once the '''Submit" button is clicked, the output is displayed on the screen. all out is displayed properly except confirmation field. I expect to view "Confirmed". Instead "array" is displayed.

___________________The script of  checkbox creation __________________________________________
<div class="confirm"><input type="checkbox" name="confirm[]" value="confirmed">      I confirm that I filled out this application form accurately at the risk of perjury.</div>
_____________________________________________________________________________________

___________ The script to view the output of $confirm ______________________________________

echo "<tr><th>Confirm Accuracy:</th><td>".$confirm."</td></tr>";

_____________________________________________________________________________________


Hope you experts may kindly help me again!

duta
June 4, 2006, at 1:06 pm
dutaAsked:
Who is Participating?
 
soapergemConnect With a Mentor Commented:
You named your checkbox "confirm[]". Do you have multiple checkboxes with this name, by any chance? If you do, good. If not, and this is your only checkbox, change the name to "confirm" (without the brackets). By having those square brackets there, it places the result into an array, so the value you are looking for would actually be in $confirm[0] (or it wouldn't be anywhere if the box wasn't checked).

Oh, and by the way, DO NOT USE $confirm TO REFERENCE THE DATA. USE $_REQUEST['confirm']. Assuming that register_globals is turned on is bad practice. If you kept the same name and used this format, the value would be in $_REQUEST['confirm'][0]
0
 
fehaConnect With a Mentor Commented:
if you have just separate check box to confirm than use as
<div class="confirm"><input type="checkbox" name="confirm" value="confirmed">

as it does not need to be an array do not use      name="confirm[]"

to display use:
echo "<tr><th>Confirm Accuracy:</th><td>".$_POST['confirm']."</td></tr>";

hope this helps

0
 
soapergemCommented:
feha beat me to it.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
dutaAuthor Commented:
TO: feha and soapergem:

Thank you so much for your very kind, prompt response.

Your tips worked just great.
I would like to split the points between you, if you may kindly not mind.

Hope you may come back to help me again!

duta
June 4, 2006, at 1:58 pm
0
 
dutaAuthor Commented:
TO: feha and soapergem:

Hi again!

I tried to split evenly (because your tips arrived almost simultaneously and worked great) and to accept both as "Accepted Answer". But it turned out against my intention that one of them is registered as "Assisted Answer" and the other as "Accpeted Answer".

Hope that this may help clear an misunderstanding.

Thanks again!  Both of you are just great!

duta

June 4, 2006, at 2:02 pm
0
 
soapergemCommented:
That's fine by me. Thanks for the split! =)
0
 
fehaCommented:
great nice it worked for you :-)

feha
 www.vision.to
0
 
dutaAuthor Commented:
TO: feha and soapergem:

Thank you so much for your kind understanding.
feha, you are creating a nice web site.

Thanks again!

duta

June 4, 2006, at 2:15 pm
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.