Checkbox form processing.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drputo
Forum Newbie
Posts: 3
Joined: Fri Jul 08, 2005 7:36 pm

Checkbox form processing.

Post by drputo »

Ok I've made up a little mock page here http://www.magicbean.ca/pizza.html

What I want to do is have some one be able to choose what toppings and extras they want then
once it is processed show the confirmation page with all the stuff that they selected complete with the price and total.

What is the way for PHP to find out if a box has been checked or not and then be able to calculate the cost.

Please help.

Thank you.

Dr. Puto
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you just need to check if the box is checked with isset, then you could add the value of the box to the total:

ex:

Code: Select all

<input type="checkbox" name="pepperoni" value="1.25">

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST['pepperoni'];
echo $price;
ice += $_POST['pepperoni'];
echo $price;
mp;quote;checkbox" name="pepperoni" value="1.25">

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST&#1111;'p($_POST['pepperoni']))
  $price += $_POST['pepperoni'];
echo $price;
of the box to the total:

ex:

Code: Select all

<input type="checkbox&quote; name=&quote;pepperoni&quote; value=&quote;1.25">

Code: Select all

$priheck if the box is checked with isset, then you could add the value of the box to the total:

ex:

Code: Select all

<input type="checkbox" name="pepperoni" value="1.25">

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST['pepperoni'];
echo $price;
<input type="checkbox" name="pepperoni" value=&quote;1.25&quote;&gt;

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST['pepperoni'];
echo $price;
e; value=&quote;1.25&quote;&gt;

Code: Select all

$price = 10.00;
if(isset($_POST&#1e9136]
<input type="checkbox&quote; name=&quote;pepperoni&quote; value=&quote;1.25&quote;&gt;

Code: Select all

$price = 10.00;
if(isset($_POST&#1111;'pepperoni']))
  $price += $_POST&#1111;'pepperoni'];
echo $price;
]
<input type="checkbox" name="pepperoni" value="1.25">

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST['pepperoni'];
echo $price;
]
ex:

Code: Select all

<input type="checkbox" name="pepperoni" value="1.25">

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST['pepperoni'];
echo $price;
you could add the value of the box to the total:

ex:

Code: Select all

&lt;input type=&quote;checkbox&quote; name="pepperoni" value="1.25">

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST['pepperoni'];
echo $price;
eckbox" name="pepperoni" value="1.25">

Code: Select all

$price = 10.00;
if(isset($_POST&#1111;'pepperoni']))
  $pric9136]

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST&#1111;'pepperoni'];
echo $price;
isset($_POST['pepperoni']))
$price += $_POST['pepperoni'];
echo $price;
then you could add the value of the box to the total:

ex:

Code: Select all

<input type="checkbox" name="pepperoni" value="1.25">

Code: Select all

$price = 10.00;
if(isset($_POST['pepperoni']))
  $price += $_POST['pepperoni'];
echo $price;
drputo
Forum Newbie
Posts: 3
Joined: Fri Jul 08, 2005 7:36 pm

Post by drputo »

Thank you Burrito,

I learned something from that but I need more.

I will post a new topic.
Post Reply