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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.