hewstone999 Posted April 3, 2009 Share Posted April 3, 2009 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>"; } ................ Link to comment https://forums.phpfreaks.com/topic/152438-radio-buttons-help-with-session-varibles/ Share on other sites More sharing options...
phpdragon Posted April 3, 2009 Share Posted April 3, 2009 something to this effect should work <?php session_start(); if (isset('submit')) { $DimOther=$_POST['col']; $_SESSION['$DimOther'] = $DimOther; header("Location: Cleanser_step3.php"); } //This will output a Radio button list echo "<form action='".$_SERVER['PHP_SELF']."' name='form2' method='POST'>"; for ($test=1; $test<=$column1; $test++){ echo "<label>"; echo "<input type='radio' name='col' value=$test" ; if (isset($DimOther) == '$test') echo 'checked'; echo ">"; echo "Column ".$test; echo "</label>"; echo "<br>"; } echo "<input type='submit' align='right' value='Next >>'>"; echo "</form>"; } ?> Link to comment https://forums.phpfreaks.com/topic/152438-radio-buttons-help-with-session-varibles/#findComment-800583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.