• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

Checkbox value to second form.

I have a mulipage form that I am trying to pass form input from one page to the next.  On page 1 I have the following checkbox:

<input name="ADD_AC" type="checkbox" id="ADD_AC" onClick="CalculateTotal(this.form)" value="Yes" checked>

On page two, I am trying to have the form input display the Yes value like this:
Add AC? <?php echo((isset($_POST["ADD_AC"]))?$_POST["ADD_AC"]:"") ?>

The Yes value needs to show up there, can this be done?

Thanks in advance!
0
pda4me
Asked:
pda4me
  • 3
  • 2
1 Solution
 
TheAnarchistCommented:
Yes, this can be done.

For security purposes, however, I would suggest that you check when you first retrieve information from the $_POST array, that $_POST['add_ac'] is either set to "Yes" or nothing at all.
0
 
pda4meAuthor Commented:
Okay, thanks.  Can you provide edits to the code above to do this?  I am trying the above and its not working.
0
 
MasonWolfCommented:
missing semicolon - gets ya every time

Add AC? <?php echo((isset($_POST["ADD_AC"]))?$_POST["ADD_AC"]:""); ?>
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
MasonWolfCommented:
actually, you might like this one better - easier to read without so many parenthesis:

Add AC? <?=isset($_POST["ADD_AC"])?$_POST["ADD_AC"]:"";?>
0
 
pda4meAuthor Commented:
Thanks Mason, that is what I was looking for.  Is there a particular benefit using one or the other?  Is there any security benefit as mentioned above?
0
 
MasonWolfCommented:
I'm not sure there's any real security risk here. I didn't understand what TheAnarchist meant in his comment. As for the one versus the other, the only benefit I can see is readability, and the value of that is entirely in the eye of the programmer.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now