FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Validate Radio Buttons?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Validate Radio Buttons? [message #182372 is a reply to message #182371] Wed, 31 July 2013 21:37 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Wed, 31 Jul 2013 15:07:17 -0400, Jerry Stuckle wrote:

> On 7/31/2013 2:20 PM, Twayne wrote:

>> Should one Validate Radio Buttons for an online website contact form?

> Good practice means you ALWAYS validate ALL information from the user.
> You may have a radio button on your form - but there is no guarantee the
> request comes on from your form.

As a follow up to Jerry, radio buttons and select lists are probably the
easiest elements to validate in the server side code because, by
definition, you expect them to be one of a discrete set of values, and if
they're not a member of that set of values, then someone is playing silly
buggers.

You could use in_array to check that the value received is in an array of
expected values, and then use the value directly; or you could switch on
the value received, with a case for each of the expected values. In both
cases, you can detect and respond as you feel appropriate for unexpected
values.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: sql order but move some rows bottom
Next Topic: OPcache in php5.5.1 on Windows
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 14:53:31 GMT 2024

Total time taken to generate the page: 0.04249 seconds