MyBB Community Forums

Full Version: Post DATA on PHP with Radio
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I know how to post data from a textbox, but could someone help me post data when someone clicks a radiobox. Here is a pic of what I want to do...
[Image: screenshot20100501at854.png]

What would I do to imput that data?

Like with a form, it would be
<input type="text" name="test" size="25" value="Enter your name here!">

$_POST["test"];

What would I do with Radioboxes?
As per w3schools;

<form>
<input type="radio" name="sex" value="male" /> Male
<br />
<input type="radio" name="sex" value="female" /> Female
</form> 

For yours the name value would be "theme" perhaps (consistently throughout each radio option) and then simple assign the value as numbers (or the theme name).

The name property ties them together from what I understand, then you'd simply call $_POST['theme']
But, how would I do it like,

If Box1 is checked, post Box1 and ect.
What do you mean? If the user selects say 'Slim', then slim will be posted as $_POST['theme']
Your radio buttons should be grouped; in other words, make sure they have the same name but different values.

<input type="radio" name="theme" value="1" /> Default
<input type="radio" name="theme" value="2" /> Bungle
<input type="radio" name="theme" value="3" /> Slim
<input type="radio" name="theme" value="4" /> TeamXbox

Using those (of course those being within your form), you grab the values doing:

$radio_value = intval($_POST['theme']);

If the default theme was selected, the value of radio_value would be 1, if the Slim theme was selected, the value will be 3, and so on and so forth.

Best Regards.
Sorry for sounding noobie, just have some more questions.

Would I have to change radio_value to 1,2,3,4 and ECT?
Anyone?
Can anyone answer the above question?
What exactly do you mean? If you're talking about the variable's POST value, no. It will do that for you based on the users selection.
So, I don't need to change any of that code. Just implement it and it will do its job? I know I sound stupid, I just want to know for further reference.
Other than the need to manipulate the data to fit your needs, it's as good as gold. Smile
Pages: 1 2 3