margamo Posted February 20, 2013 Share Posted February 20, 2013 Maybe I am trying do the impossible I want to create a subscription form in which a user can choose from 3 different magazine subscriptions with check boxes and then choose with raidio buttons the number of months for the subscription. It doesn't pass through my data validation. I am not sure if my I am addressing the multi- dimensional array correctly. And I am not sure if use of check boxes and radio buttons is a good approach. Well anyway thanks for your help in advance. order_summaryv3.phpsubscribev3.phporder_summaryv3.php Quote Link to comment https://forums.phpfreaks.com/topic/274707-check-boxes-radio-buttons-and-multi-dimensional-arrays/ Share on other sites More sharing options...
mweldan Posted February 20, 2013 Share Posted February 20, 2013 <?php //on subscribev3.php you forgot to change value for 36 months on all three options // 36 months at $300<input type="radio" name="imonth" value="24" /> <br /> <- should be 36 //process the form //this is how the array looked like /* [subscription] => Array ( [0] => computer [1] => illustration [2] => wallpaper[] ) [month] => 24 [imonth] => 24 [wmonth] => 24 so.. 0 -> computer 1 -> illustration 2 -> wallpaper month -> months of subscription for computer magazines imonth -> months of subscription for illustration magazines wmonth -> months of subscription for wallpaper magazines */ //i have no idea how you define valid here though //you can check it like this if (isset($_GET['subscription'][0]) && isset($_GET['month']) ) { echo 'computer mag selected for '.$_GET['month'].' months!'; } if (isset($_GET['subscription'][1]) && isset($_GET['imonth']) ) { echo 'illustration mag selected for '.$_GET['month'].' months!'; } if (isset($_GET['subscription'][2]) && isset($_GET['wmonth']) ) { echo 'wallpaper mag selected for '.$_GET['month'].' months!'; } exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/274707-check-boxes-radio-buttons-and-multi-dimensional-arrays/#findComment-1413558 Share on other sites More sharing options...
mweldan Posted February 20, 2013 Share Posted February 20, 2013 maybe validation here means you want to know if no magazine has been selected? //you can use count to count array if (count($_GET['subscription']) == 0) { //show error message } hope it helps. Quote Link to comment https://forums.phpfreaks.com/topic/274707-check-boxes-radio-buttons-and-multi-dimensional-arrays/#findComment-1413570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.