Radio Button Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hewstone
Forum Newbie
Posts: 14
Joined: Fri Nov 14, 2008 10:57 am

Radio Button Help

Post by hewstone »

I have some code below that outputs a Radio button list. This will create about 6 different Radio points. However im stuck on how i can create a session varible for each Radio button, so everytime a user clicks on the Radio button (or on the 'submit' button) this will create a session varible with the value = $test. Session_start() has been added before this code
.............
//This will output a Radio button list
echo "<form action='Cleanser_step3.php' name='form2' method='POST'>";
for ($test=1; $test<=$column1; $test++){
echo "<label>";
echo "<input type='radio' name='Col$test' value=$test" ;
if (isset($fields['Col$test']) == '$test') echo 'checked';
echo ">";
echo "Column ".$test;
echo "</label>";
echo "<br>";
}
echo "<input type='submit' align='right' value='Next >>'>";
$_SESSION['$DimOther'] = $DimOther;
echo "</form>";
}
................
nyoka
Forum Commoner
Posts: 45
Joined: Thu Apr 09, 2009 12:53 pm

Re: Radio Button Help

Post by nyoka »

You could do something like:

Code: Select all

 
if ($_POST) { // posted data detected
    .... clean posted data ....
   $_SESSION['variable_name'] = 'value';
}
 
Hope this helps.
Post Reply