unemployment Posted July 28, 2011 Share Posted July 28, 2011 I'm creating a multi step form but $_POST['acc_type']; is not working properly. Sometimes it will post correctly and other times it goes to the error message even after I preform the exact same steps. It is not being posted the same everytime. Is there a better way to do this? <?php $step = 1; if(isset($_POST['continue_1']) && isset($_POST['acc_type'])) { echo $_POST['acc_type']; if(($_POST['acc_type'] != '') && (($_POST['acc_type'] == 0) || ($_POST['acc_type'] == 1))) { $step = 2; } else { echo '<p class="errormessage error">To create an account you must select a goal.</p>'; } } if($step == 1) { ?> <form action="join.php?key=<?php echo $_GET["key"]; ?>" method="post" id="form" name="signup"> <fieldset class="fieldset2"> <legend>Primary Goal</legend> <h2 class="mts">What goal do you want to achieve?</h2> <div class="ptm pbs phm tcenter"> <input id="entButton" class="radioAlign" type="radio" name="selector" value="1" /> <label for="entButton" class="entrepreneur mrl">venture</label> <input id="invButton" class="radioAlign mll" type="radio" name="selector" value="0" /> <label for="invButton" class="investor">flow</label> </div> </fieldset> <div class="signUp mbl pbl" id="continue"> <input type="submit" id="continuebtn" name="continue_1" value="Continue" /> <input type="hidden" name="acc_type" value="<?php echo (isset($_POST['selector'])) ? $_POST['selector'] : ''; ?>" /> </div> </form <?php } else if($step == 2) { echo "This is step 2"; } ?> Link to comment https://forums.phpfreaks.com/topic/243051-cant-get-radio-checked-to-post/ Share on other sites More sharing options...
Pikachu2000 Posted July 28, 2011 Share Posted July 28, 2011 Something has to be different. Have you tried to print_r() the $_POST array and compare the differences between when it works and when it doesn't? Link to comment https://forums.phpfreaks.com/topic/243051-cant-get-radio-checked-to-post/#findComment-1248298 Share on other sites More sharing options...
unemployment Posted July 28, 2011 Author Share Posted July 28, 2011 Something has to be different. Have you tried to print_r() the $_POST array and compare the differences between when it works and when it doesn't? No, I've never done it. The $_POST variable is an array? I suppose that makes sense. Let me try it. Link to comment https://forums.phpfreaks.com/topic/243051-cant-get-radio-checked-to-post/#findComment-1248301 Share on other sites More sharing options...
unemployment Posted July 28, 2011 Author Share Posted July 28, 2011 Wow... thank you. I printed the array and was able to fix my problem. I didn't even need to use the hidden input. Apparently the input with the name selector was already being posted. Thank you for increasing my knowledge of php Link to comment https://forums.phpfreaks.com/topic/243051-cant-get-radio-checked-to-post/#findComment-1248302 Share on other sites More sharing options...
Pikachu2000 Posted July 28, 2011 Share Posted July 28, 2011 Yeah, it's an array. It's probably best to print_r() it inside of <pre> tags so gets formatted for easier readability. echo '<pre>'; print_r($_POST); echo '</pre>'; Link to comment https://forums.phpfreaks.com/topic/243051-cant-get-radio-checked-to-post/#findComment-1248303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.