Jump to content

check boxes radio buttons and multi-dimensional arrays


margamo

Recommended Posts

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

<?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;


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.