Jump to content

Processing radio boxes and hidden form fields at the same time


xkyogre

Recommended Posts

I have a form that needs to be checked.

It contains 4 radio boxes a submit button and 4 different hidden fields.

How do I get my php script to check if a radio box has been selected and tell the user to check a radio box if he hasn't?

The script I am currently using doesn't work; if the user chacks some thing then it proceeds as usual, but if it is left blank then the program freezes up and nothing is displayed apart from the stuff outside the <?php?> tags.

Do you think we could see your code that you have? Dont forget to enclose it in

 tags(without the spaces)

However, to answer what i think is your question, say you had the following radio button:

[code]
<input type='radio' name='yourfield' value='option1' />

 

Then to check if this option had been selected, you would use:

<?php
if($_POST['yourfield'] = 'option1'){
//option1 selected
}
?>

 

Of course, if your form method was get, use the $_GET array.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.