PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
But this does only seems to work when it is not an array, all boxes get checked when the submit button is clicked. I would like to use an array because of validations purposes.
Well, to determine if you should says it is checked, you are doing the following:
isset($_POST['submissions']) == 'Visit Web'.
Well as long as one checkmart is placed isset($_POST['submissions']) will be equal to true
When it comes to comparing, you are comparing a Boolean (TRUE from the isset) to a string. So PHP evaluates each string to be a boolean value, and since they are not blank, that ends up being TRUE.
so you are saying IF (TRUE == TRUE) set the checkbox to be selected.
(isset($_POST['submissions]) && in_array('Visit Web',$_POST['submissions])) is something you are more likely looking for.
Thank you so much Greg, I now see where my mistake was!!
I fixed it and it worked flawlessly!
I looked everywhere before posting here and did not find anything. I am now in debt with you, sir.
For anyone having the same problem, this is the complete code that I am using and its working perfectly (thanks to Greg)
you don't need the == 'Visit Web' in there because it will always evaluate as TRUE since it is being compared against a boolean. It is just wasted code not needed.
Yes, you are right. It was wasted code since I tested the form without the =='Visit Web' and it works perfectly also.
I must admit, I am not very familiar with the function in_array() yet.
I will have to do more reading on that.
I greatly appreciate your help. And for this I thank you again.