snip for selection processing

Hi,

I have this code in my form processor, and would like to add selection dropdown, checkboxes and radio buttons, but don’t know how to do it in the same fashion of the other fields.
I got the code from the web, and would like to just integrate the code with similar structure.

I think I can manage the rest of it, if I get the elseif snip.

Thank you

the html example

[php]


Room Choice
Choose One: Single (all booked) Double Triple Quadruple
Male Female
Usher Desk
[/php]

and the php

[php]//Name
}elseif(!preg_match("/^[a-zA-Z’ -]{2,}/", trim($_POST[‘name’]))){
$error .= “
Name does not pass validation\n”;

//Lastname
}elseif(!preg_match("/^[a-zA-Z’ -]{2,}/", trim($_POST[‘lastname’]))){
$error .= “
Lastname does not pass validation\n”;[/php]

None really needed…

First, take the drop-down. In each option, you have a set value that the user can not change.
Such as the third one in your example. If they select “Double”, the posted value will always be
“double”. No checking needed. But you will need to see if the checked “na” or made a selection.

For checkboxes, you just check if the are checked or not. No preg_match needed.

For radio-buttons, you just read the value of the radio. You have a sample where you create a radio
group named “gender”. It contains to ID’s with two values. Just read the $_POST[‘gender’] and it will
always be either value “male” or value “female” as those are the only two you put in there. No type of
validation needed.

Hope that is what you where asking.

Sponsor our Newsletter | Privacy Policy | Terms of Service