Jump to content

ctmarco3

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ctmarco3's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I wondered about using array from the research I had done but wasn't quite sure how to implement it, let me do some additional research and see if I can take your advice and actually integrate it into my form. Thanks so much! I may be back, but hopefully not.
  2. OK that makes sense, thank you everyone for the replies. What I don't get than is how to get the value for my variable pushed to my $sum command. Is there a way to say do something like this perhaps?: If the box is checked than my $four100wattreg = 2.39, if the box is unchecked than $four100wattreg = 0 What would be the best way to handle that? to explain this post further so you understand why it is not correct, when you set the variable $four100wattreg = $_POST["four100wattreg"]; and then again $four100wattreg=2.39; you are overwriting the first value that you set $four100wattreg to with the new value (2.39). You should be using unique variable names for each unique value that you want PHP to remember. if (!isset($_POST['checkbox']) { //checkbox not checked $four100wattreg = 0; } where is $_POST['checkbox'] being passed to the server?
  3. Hello all I am working on creating a basic ordering form that allow the user to use check-boxes to select certain products and than return a total back to them. I am having a hard time figuring out the php code to gather and calculate things. What I dont quite understand is how to pass the data properly so my $sum calculation actually knows what the values are... In my html doc I have my checkboxes as follows: //formatted in tables <input type = "checkbox" name = "eight100wattreg" size ="40" /> <input type = "checkbox" name = "four100wattreg" size ="40" /> //etc.... and in my php doc: <?php> //get form values $four100wattreg = $_POST["four100wattreg"]; $eight100wattreg = $_POST["eight100wattreg"]; $four100wattlong = $_POST["four100wattlong"]; $eight100wattlong = $_POST["eigth100wattlong"]; $payment = $_POST["payment"]; //set lightbulb values $four100wattreg=2.39; $eight100wattreg=2.39; $four100wattlong=2.39; $eight100wattlong=2.39; //calculate costs if (isset($_POST['four100wattreg']) { //checkbox is checked $four100wattreg = $_POST['four100wattreg']; } else if (!isset($_POST['checkbox']) { //checkbox not checked $four100wattreg = 0; } $sum = $four100wattreg + $eight100wattreg + $four100wattlong + $eigth100wattlong; ?> <?php> echo "Your total is: '$sum' <br />"; ?> I also attached the files if someone wants to look at them in they're entirety. Any advice would be greatly appreciated, but please keep in mind I am a php beginner and am still learning. Thanks, Charlie 17386_.txt 17387_.php
×
×
  • 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.