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

Link to comment
Share on other sites

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


?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.