Page 1 of 1

Checkbox form processing.

Posted: Fri Jul 08, 2005 7:41 pm
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

Posted: Fri Jul 08, 2005 8:08 pm
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;

Posted: Sat Jul 09, 2005 2:40 am
by drputo
Thank you Burrito,

I learned something from that but I need more.

I will post a new topic.