Hey I have this form:
<p>How long have you been playing cs:<br>
<input type="radio" name="cstime" value="6 Months">6 Months<br>
<input type="radio" name="cstime" value="1 Year">1 Year<br>
<input type="radio" name="cstime" value="2 Years">2 Years<br>
<input type="radio" name="cstime" value="2 1/2 Years and up">2 1/2 Years and up<br><br>
</p>
I would like to know how I can get the value of the radio button that was pushed and store it into a variable in the php script that processes this form.
Thanks for all help and advice provided.
Finding out which radio button has been checked
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you put:
into the form processing script you will be able to see all of the information that has been posted. The information from the radio button will be available as $_POST['cstime'].
Mac
Code: Select all
echo '<pre>';
print_r($_POST);
echo '</pre>';Mac
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Yup but put quotes around the array element
instead of
See Array do's and don'ts on this page for why:
http://www.php.net/manual/en/language.types.array.php
Mac
Code: Select all
$radioButtonPushed = $_POST['csTime'];Code: Select all
$radioButtonPushed = $_POST[csTime];http://www.php.net/manual/en/language.types.array.php
Mac
Variables in PHP are case-sensitive.
will give you the value of your radio-button after the form has been submitted.
Code: Select all
<?php$radioButtonPushed = $_POST['cstime'];?>