Basic checkbox program - I need some help

I set up a simple lunch menu. The user can check the items desired and the program should return prices and total.

But, it’s not - HELP!

I just started with PHP and this type of survey/order form will be of great use to me. I need to accomplish this and uderstand it. Any help will be very, very much appreciated.



Checkbox Demo

Checkbox Demo

Demonstrates checkboxes

What would you like with your order?

  • Fries
  • Soda
  • Shake
  • Ketchup



Checkbox Demo

Checkbox Demo

Demonstrates reading checkboxes

<?php print <<<HERE chkFries: $chkFries
chkSoda: $chkSoda
chkShake: $chkShake
chkKetchup: $chkKetchup

HERE; $total = 0; if (!empty($chkFries)){ print ("You chose Fries
n"); $total = $total + $chkFries; } // end if if (!empty($chkSoda)){ print ("You chose Soda
n"); $total = $total + $chkSoda; } // end if if (!empty($chkShake)){ print ("You chose Shake
n"); $total = $total + $chkShake; } // end if if (!empty($chkKetchup)){ print ("You chose Ketchup
n"); $total = $total + $chkKetchup; } // end if print "The total cost is $$total n"; ?> [/code]

What does this part output:

[code]print <<<HERE

chkFries: $chkFries

chkSoda: $chkSoda

chkShake: $chkShake

chkKetchup: $chkKetchup


If it doesn’t output the values for the variables, then your server has register_globals switched to off. In that case, use the $_POST superglobal variable to retrieve your data from the form.

Thanks for your insight!!!

I simply went into my php.ini file and turned "on " register_ globals and reran the program.

It works fine.

QUESTION: Is there an advantage to leaving register_globals “off” and learning the $_post funtionality. And if so, are you aware of an info source that can teach me this funtionality.

Sponsor our Newsletter | Privacy Policy | Terms of Service