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