Jump to content

php checkboxes


ironmaiden666

Recommended Posts

I tried these also but they don't work out I tried your tips but in vain...

this one is ok

 

<html>

<head>

<title>Checkbox Demo</title>

</head>

<body>

<h1>Checkbox Demo</h1>

<h3>Demonstrates checkboxes</h3>

<form method ="post"

action ="checkDemo.php">

 

<h3>What would you like with your order?</h3>

<ul>

<li><input type ="checkbox"

name ="chkFries"

value ="1.00">Fries

</li>

<li><input type ="checkbox"

name ="chkSoda"

value =".85">Soda

</li>

<li><input type ="checkbox"

name ="chkShake"

value ="1.30">Shake

</li>

<li><input type ="checkbox"

name ="chkKetchup"

value =".05">Ketchup

</li>

</ul>

<input type ="submit">

</form>

</body>

</html>

 

but this one not...

 

<html>

<head>

<title>Checkbox Demo</title>

</head>

<body>

<h3>Demonstrates reading checkboxes</h3>

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

?>

</body>

</html>

 

I tried to do it like this:

<?php

$chkFries = $_GET["chkFries"];

$chkSoda = $_GET["chkSoda"];

$chkShake = $_GET["chkShake"];

$chkKetchup = $_GET["chkKetchup"];

$total = $_GET["total"];

print <<<HERE

Link to comment
https://forums.phpfreaks.com/topic/67425-php-checkboxes/
Share on other sites

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.