Okay, first, let’s start with your samples you just posted… It appears your code is working as you did
program it. But, I think it is NOT what you wanted it to do. Let’s explain so you are clear, or we both are…
You are using “drop-down” select clauses, NOT checkboxes as you mentioned. The drop-downs are okay,
but, for a yes, no option, I think that a real checkbox nicer. (add a title “Select support options you wish”)
You should consider changing them to radio’s… But, for this discussion, let’s leave them as drop-down’s.
So, let’s talk about the “phone-support” one only. It has two options, either yes or no. Once this is in the
browser, the user will see the default, usually the first option but can be whichever you set it to be.
It’s code:
[php]
Phone Support:
Yes
No
[/php]
So, this code set's the default to be "Pen1" and shows the user "Yes". Once the submit button is pressed,
the page "POSTS" this data to the form's submit page. At this point each SEPARATE select clause has a value
which can be read. Such as "Sphone". In this case, it can be either NULL ("") or "Yes". Since these are the
two value you placed into the options for this select. One problem with this is that if they select "No", then
nulls are involved. When the "data" for the option is read, it may be set to null and you can not use that
value. Reading the "value", such as in PHP, $Sphone=$_POST['Sphone']; may give you an error. You can
do it in this manner: if(isset($_POST['Sphone'])) {do something...} This will check if null and if not it will
let you do something. If you are saving your data inside a database, it is usually better to use real data for
each option and then you can just capture the values and not have to test for NULLs. Either way will work.
But, you must know which way you are handling it.
Therefore, in this section of your code:
[php]
if(isset($_POST[‘Sphone’]) && isset($_POST[‘Schat’]) && isset($_POST[‘Smeet’]) && isset($_POST[‘Sremo’]) && isset($_POST[‘Sport’]) && isset($_POST[‘Smail’]) && isset($_POST[‘Svoic’]) && isset($_POST[‘Sfax’])) {
$_POST = array_map(“strip_tags”, $_POST); // Gets rid of tags in POST Call
// get data
$Sphone = $_POST[‘Sphone’];
[/php]
You are testing for all your fields and if they are all set, you get the data. This will never work because you
are using nulls for the “NO” version of the options in the select tags. If, let’s say, the user does not select
“Sport”, then the if statement will NEVER be valid as the “Sport” value will be null and NOT be set. And, this
would make the IF to be false. So, most likely you just have to change all your options to include Yes/No
instead of Yes/NULL. Also, normally, this would be a list of options that would be selected not a drop-down.
So, normally it would be something like:
[php]
Select your support options you wish to use:
Phone Support
Live Chat Support
Email Support
[/php]
Something like that. Then, the all of the options would be inside an array called “options”. In PHP, you
could then loop thru the options and all checkboxes that are “CHECKED” would be in the array. If array is
empty, then, no options were checked. You can just store the entire array into your database and load it
back in as needed to display the options that the user previously selected.
Well, not sure if all of this helped or not. If not, please ask further questions…