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!
pda4meAsked:
Who is Participating?
 
MasonWolfCommented:
missing semicolon - gets ya every time

Add AC? <?php echo((isset($_POST["ADD_AC"]))?$_POST["ADD_AC"]:""); ?>
0
 
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
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
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.