PHP - Adding An If To Post On A Checkbox Form
Trying to fix existing some code (complete beginner here) on the company I work for website.
There's a check-box which when ticked should apply delivery charges and if not it shouldn't - currently it's working in that on the same page it calculates the total cost correctly when checked or not checked but when passing on information it always passes on the delivery charge even if un-ticked... The simplest thing I can see would be to put an if statement in to say if (not ticked) then del_charges = 0.00. Any idea how I can do this in this instance? Code: [Select] <?php // add a checkbox for delivery charges echo '<span class="form"><label>Delivery Charges</label>'; echo '<input type="checkbox" name="del_charges" id="del_charges" value="1" class="boxes" '; if ( isset($_POST['del_charges']) && !empty($_POST['del_charges']) ) echo 'checked="checked"'; echo '/>'; ?> Thanks. Similar TutorialsDoes anyone no a way to post a unchecked checkbox value? Hey I have checkbox and when the user tick one or more box these should be stored as 0 or 1 but since its while loop, I am not sure how to work that out. So far I have <html> <?php session_start(); include '../Database/connection.php'; $Value24 = mysql_real_escape_string(trim($_POST['myselect'])); $_SESSION['smodule'] = $Value24; ?> <body> <form action="Test_Completed.php" method="post"> <?php $query = mysql_query(" SELECT * FROM Test WHERE Tes_ID = '{$_SESSION['smodule']}' "); while( $query1 = mysql_fetch_array($query) ) { echo "Test Name: {$query1['Tes_Name']}"; } ?> <br> <?php $query = mysql_query(" SELECT * FROM User WHERE Use_ID = '{$_SESSION['ssubject']}' "); while( $query1 = mysql_fetch_array($query) ) { echo "User Name: {$query1['Use_Name']}"; } ?> <br> <?PHP include '../Database/take_an_exam.php'; $intNumber = 1; while($info = mysql_fetch_array( $sql )) { echo "$intNumber, {$info['Que_Question']} <br />\n"; echo "<input type=\"checkbox\" name=\"choice1[]\" value=\"{$info['Que_Choice1']}\" /> "; echo "{$info['Que_Choice1']} <br />\n"; echo "<input type=\"checkbox\" name=\"choice2[]\" value=\"{$info['Que_Choice2']}\" /> "; echo "{$info['Que_Choice2']} <br />\n"; echo "<input type=\"checkbox\" name=\"choice3[]\" value=\"{$info['Que_Choice3']}\" /> "; echo "{$info['Que_Choice3']} <br />\n"; echo "<input type=\"checkbox\" name=\"choice4[]\" value=\"{$info['Que_Choice4']}\" /> "; echo "{$info['Que_Choice4']} <br />\n"; $intNumber++; } ?> <input type="submit" value="submit"/> </body> </html> </body> </html> <?PHP $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Examination", $con); //Get & clean value from POST data $choice1 = mysql_real_escape_string(trim($_POST['choice1'])); $choice2 = mysql_real_escape_string(trim($_POST['choice2'])); $choice3 = mysql_real_escape_string(trim($_POST['choice3'])); $choice4 = mysql_real_escape_string(trim($_POST['choice4'])); $user = mysql_real_escape_string(trim($_SESSION['username1'])); //Create and run INSERT query $query = "INSERT INTO Answer (`Ans_Answer1`, `Ans_Answer2`, `Ans_Answer3`, `Ans_Answer4`, `Que_ID`, `Use_ID`) VALUES ('{$choice1}', '{$choice2}', '{$choice3}', '{$choice4}', '{$query1}', '{$user}')"; $result = mysql_query($query) or die (mysql_error()); $_SESSION['Ans_ID'] = mysql_insert_id(); header("location:check.php"); ?> Hey Guys,
I'm really struggling to find whats wrong with this code. The form before submit has several checkboxes as part of an array which is below
The next page then goes to this and I get the error "Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /homepages/39/d837976904/htdocs/Scheduler/add_job3.php:10 Stack trace: #0 {main} thrown in /homepages/39/d837976904/htdocs/Scheduler/add_job3.php on line 10"
<?php $process = $_GET["process"];
include "Includes/config.php";
$checkBox = implode(',', $_POST['engineers']);
if(isset($_POST['submit'])) mysql_query($query1) or die (mysql_error() ); echo "Complete"; }
?> Can anyone help with the code please Hi all. I try to adding checkbox when I call my function, my Class code is Code: [Select] class SQLconn{ function fetchData($table_name, $argument, $linebreak, $end_linebreak){ $result = mysql_query("select * from $table_name where status='$argument'"); while($row=mysql_fetch_row($result)){ echo $linebreak.$row[1]."<input type='checkbox' name='option' id='checkbox' value=$row[0] />".$end_linebreak; //$row[0] is 'job_id' from database } } } and my view code is like this Code: [Select] <?php $connect = new SQLconn(config()); $connect->connectDB(); $connect->fetchData("todo", "Undone", "<li>", "</li>"); //this is where the problem is $connect->closeConn(); ?> With that code I succesfully achieve my goal to add checkbox with right 'job_id' value but this is a workaround and not good because if I code it this way my function will be broken if use it somewhere else. My question is, how can I fix my code so I can add checkbox to view page but I can keep my function clean? Really need opinion about this?? Hey Guys. I am working with a form that shows the grand total on the checkout page. The value of the grand total is inside a hidden field. When click on submit, the _POST array doesn't get back the last value of the grand total. I need to hit the button twice to get the last value. The weird thing is when I echo the value of the grand total it display the latest value, but not with the POST array
For example. If the grand total is $10.00 and I click on submit. It will show the POST['grand_total'] as empty. If I click on submit again it will show the grand total of $10.00.
Below is my code that I am working with. Any help would be really appreciated.
if(isset($_POST['submit'])) { /* Doesn't show if i put it after if($_POST['submit'] */ if(isset($_POST['grand_total'])) { echo $_POST['grand_total']; } } //A bunch of other html/php code. Another class calculates the subtotal assigns it the variable $subtotal $cart_totals = new cartTotals($subtotal, $discounted_amount,$post_values->tip); // Cart class is shown below /* Doesn't show if i put it before if($_POST['submit'] */ if(isset($_POST['grand_total'])) { echo $_POST['grand_total']; } echo "<input name='grand_total' type='hidden' value='$cart_totals->grand_total' />"; // Shows the grand total after second from submission echo "$cart_totals->grand_total"; // Shows grand total after the first submissionCart Totals Class class cartTotals { public $subtotal; public $sales_tax; public $tip; public $grand_total; public $discount_amount; public $href_page; public $invalidCouponMessage; const TEST_ENVIORMENT = FALSE; /** * [ Function gets constructed in the order summary where the [$discount_amount= ""] arg does need to be passed. * But does get passed in when called on the checkout.php page. Therefore we set the default value to an empty string.] * @param [float] $subtotal [subtotal get passed in from the parent class coreCartFunction] * @param string $discount_amount [The class checkCouponCode calculates this discount amount based on the * subtotal and the discount amount. It gets instantiated on the clients side and passed is this construction function. * This is all done on the checkout page.] */ /*The way the construct function works is by invoking all the methods the passed arguments When the methods get invoked the do all the work and set the properties its values. The properties then get echoed out on the client side. */ function __construct($subtotal="", $discount_amount= "", $tip=""){ $this->subTotal($subtotal, $discount_amount);//SubTotal method takes the discount amount and subtracts it from the subtotal. $this->salesTax($subtotal, $discount_amount); $this->tip = $tip; $this->grandTotal(); } private function subTotal($subtotal,$discount_amount) { $rounded_subtotal = round($subtotal-$discount_amount,2); $money_format_subtotal = money_format('%i',$rounded_subtotal); $this->subtotal = $money_format_subtotal; } private function salesTax($subtotal, $discount_amount =""){ $sales_tax = (STORE_SALES_TAX)?(float)STORE_SALES_TAX:8.875; $sales_tax =(($this->subtotal)*$sales_tax)/100; $sales_tax = round($sales_tax,2); $this->sales_tax = $sales_tax; } public function Tip() { //global $post_values; //$last_tip_selected = $post_values->tip > 0 ? $post_values->tip : "" ; $tip_output = "<select id='tip' name='tip'>"; for($tip=0.00; $tip<=11.75; $tip+=0.25){ if( $tip == "2") {$selected = " selected";} else {$selected ="";} $formatted_tip = money_format('%i',$tip); $tip_output .= "<option {$selected} id='selected_tip' value='$formatted_tip'>"."$".$formatted_tip ."</option>".PHP_EOL; } $tip_output .= "</select>"; return $tip_output; } private function grandTotal(){ $grand_total = round($this->sales_tax+$this->subtotal+$this->tip,2); $grand_total_formatted = money_format('%i',$grand_total); $this->grand_total = $grand_total_formatted; } Right now I have a search option on my site that searches the database for whatever the user puts in. Well then they can click on a record and they can edit it. What I am trying to accomplish is whenever a user clicks to edit but then decides that was the wrong record they can hit a back button and it will show them their results with what they typed in earlier. If they just click the back button on top they get a "Do you want to resubmit the form". I tried the <a href="#" onclick="history.go(-1);return false;" class="mtn"> Find out that only works on Safari and that isn't good code. Then I tried this... <input type="hidden" name="qry" value="<?=$qry_str?>"> $qry_str is my "SELECT" statement and I am just sending it to my update page as a variable with the POST. On my update page I pull the variable, save it in another one and send it back to the search page if the user clicks the back link. However it keeps adding a '' on both sides of the criteria everytime I send it to a page. For instance, I have: SELECT * FROM tasks WHERE 1 and Owner='cnj'. Then I echo on my update page and its SELECT * FROM tasks WHERE 1 and Owner=''cnj'', then I click the back link and get this: SELECT * FROM tasks WHERE 1 and Owner=''''cnj''''. It is doubling them up everytime. Code on the update page looks like this if you wanted to see <?php $search=$_POST['qry'];?> <FORM name="form1" action="searchtasks.php" method="post"> <input type="hidden" name="return" value="<?=$search?>"></FORM> <a href="javascript: submitform()">Back</a> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347360.0 i have this in a loop and a form Code: [Select] <input type='checkbox' name='$topic' value='No' /> on the page the form directs to. How do i get each separate topic that has been checked? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=326600.0 Hi, I am using check box group in my php form, The user can choose multiple answers, if he choose 3 answers and the form is submitted only one answer is displayed in mysql Code: [Select] GetSQLValueString($_POST['father'], "text"), any help please? Thanks Hi: Is this the correct way to do a memory form for a checkbox? Code: [Select] <input name="status[]" id="pending" value="<?=$_POST['pending'] ?>" type="checkbox" /> Why is it grouping the checked boxes instead of keeping them in order like area is? if(isset($_POST['submit'])){ for($i=0; $i<10; $i++){ echo "<br />Ignore = [".$_POST['ignore'][$i]."]"; if($_POST['ignore'][$i]!="true") echo ", Area = ".$_POST['area'][$i]; } } else { echo "<form method='post'><table>"; for($i=0; $i<10; $i++){ echo " <tr> <td><input type='checkbox' name='ignore[]' value='true' /></td> <td><input type='text' name='area[]' /></td> </tr>\n"; } echo " </table> <input type='submit' name='submit' value='Submit' /> </form>"; } Input: Quote Checked - ignored Unchecked - a Checked - ignored2 Unchecked - b Checked - ignored3 Unchecked - c Unchecked - d Checked - ignored4 Unchecked - e Checked - ignored5 Output: Quote Ignore = [true] Ignore = [true] Ignore = [true] Ignore = [true] Ignore = [true] Ignore = [], Area = c Ignore = [], Area = d Ignore = [], Area = ignored4 Ignore = [], Area = e Ignore = [], Area = ignored5 Hey I'm a beginner at this and I was hoping the answer might be something simple. I'll post the code if needed, but it might just be something simple. I have a contact form with a php script to email me when a user enters information. I have a checkbox for whether or not a user wants to receive our newsletter. When a user fills in his/her information. Clicks the checkbox to receive our newsletter, then clicks submit they are then taken to a thank you page and I receive an email with their info, etc. When a user fills in his/her information. DOES NOT click the checkbox, then clicks submit, nothing on the screen changes, but I still receive the email with their info. Why is this happening? What am I missing with this checkbox? How do I get the thank you page to still display if they DO NOT click the checkbox? Any thoughts would be appreciated. if($x==""){
$x=1;
}
while($do=mysql_fetch_array($sql){
<form name='Form' action='posting.php' method='post'>
<input type='checkbox' name='<?php print $x; ?>' value='<?php print $do[id]; ?>' />
<input type='submit' name='checked' value='checking'>
$x++;
}
When I click on the submit button, only one value of $x is sent to posting.php instead of multiple loop values in checkbox. Does anyone have a solution to it ?
Under Posting.php
for ($x = 1; $x <= 20; $x++) { $x=$_POST[$x]; echo "$x"; } Edited by sungpeng, 16 October 2014 - 09:41 PM. This is related to how PHP processes checkboxes in a form. I have a checkbox in a form called chkNewpart: $s='<tr><td>Model: <td><input type="text" name="txtModelnum" id="txtModelnum" value="'.$row['modelnum'].'" size="20" maxlength=15 />'; $s.=' New part? <input type="checkbox" name="chkNewpart" value="'.$newpartvar.'" '; $s.='checked="'; if ($newpartvar==1) { $s.='checked'; } $s.='" />'; $s.='</tr>'; In my db, the field that holds this value is a tinyint, and the default is 1, which stands for true. So when I display the checkbox, if the value of the field is 1, then the box should be checked. That part works. The problem I have is when I uncheck the box and save the checkbox to a php variable, and then the database field. $newpartvar=$_POST['chkNewpart']; ... $query = "UPDATE parts SET modelnum='".$modelvar."', ". "prodcat='".$prodcatvar."', ". "prodname='".$prodnamevar."', ". "prodsubname='".$prodsubnamevar."', ". "newflag="; if ($newpartvar==1) { $query.="1"; //True } else { $query.="0"; //False } $query.=", "; $query.="updateuser='".$_SESSION['username']."', ". "updatedate=NOW() ". "WHERE partid=".$partidvar.";"; I get no errors but php doesn't seem to change the field value, when I look at it in PHP Admin. How do I handle the values of checkboxes properly? I'd like 1 to be true and 0 to be false. helo does anyone know how to display data from db in checkbox form? i have been searching for days and still cannot find answer that i can understand. i hope someone can help me. i really am lost. any help is much appreciated Hi. My form involves a checkbox. Below is the code. The problem is that when I am not sure what to put on the php. I need for people to be able to check one box tow boxes or all three boxes. On the form side I have this: type="checkbox" name="formcheck[]" value="C". Not sure what to put on the php side and need some assistance Code: [Select] <label style="display: block; padding-left: 15px; text-indent: -15px; width:650px;"> <input style="width: 45px; height: 45px; padding: 0; margin:0; vertical-align: bottom; position: relative; top: -1px; *overflow: hidden;" type="checkbox" name="formcheck[]" value="A" /> Directory Listing </label> <label style="display: block; padding-left: 15px; text-indent: -15px;width:650px;"> <input style="width: 45px; height: 45px; padding: 0; margin:0; vertical-align: bottom; position: relative; top: -1px; *overflow: hidden;" type="checkbox" name="formcheck[]" value="B" /> Full page listing </label> <label style="display: block; padding-left: 15px; text-indent: -15px;width:650px;"> <input style="width: 45px; height: 45px; padding: 0; margin:0; vertical-align: bottom; position: relative; top: -1px; *overflow: hidden;" type="checkbox" name="formcheck[]" value="C" /> Receive a link to your website </label> Hi all, Im creating a simple quiz where some of the questions are checkbox because there is more than one correct answer. What I would like to be able to do, is run an if statement to check if, say for example, options 1 and 5 out of 6 have been selected, then award the point. However the point is only awarded is both options are selected. Any suggestions? Thank you in advance So I got help from here earlier with one problem and a few more have arisen, the biggest is for some reason my checkbox and dropdown array won't store the data and when it's supposed to check to verify there is at least 1 selected of each nothing happens... To be honest the ideal thing would be to have it check to see if the drop down size selection below the checkbox was selected, but I'll do whatever as long as it works. Thanks ahead of time for the help. Here's my page code: Code: [Select] <html> <HEAD> </head> <body> <?php require_once "formvalidator.php"; $error_hash = 'no'; $show_form = true; class MyValidator extends CustomValidator { function DoValidate(&$formars,&$error_hash) { if(stristr($formars['comments'],'http://')) { $error_hash['comments']="No URLs allowed in comments"; return false; } return true; } } if ($_SERVER['REQUEST_METHOD'] == "POST") { $validator = new FormValidator(); $validator->addValidation("email", "email", "<B>Email address is invalid.</B>"); $validator->addValidation("first", "req", "<B>Please provide your First name for invoice.</B>"); $validator->addValidation("last", "req", "<B>Please provide your Last name for invoice.</B>"); $validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>"); $validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>"); $validator->addValidation("state", "req", "<B>Please provide your State for invoice.</B>"); $validator->addValidation("zip", "num", "req", "<B>Please provide your zip for invoice.</B>"); $validator->addValidation("phone", "num", "<B>Numbers only in phone number.</B>"); if ($validator->ValidateForm()) { $show_form = false; } else { echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>"; $error_hash = $validator->GetErrors(); foreach ($error_hash as $inpname => $inp_err) { echo "<center><p>$inpname : $inp_err</p></center>\n"; $show_form = true; } } $pic = $_POST['pic']; if(empty($pic)) { echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>"; } else { $r = count($pic); for($i=0; $i < $r; $i++) { echo "picture(s) requested $i was: " . $pic[$i] . "\r\n"; } } $size = $_POST['size']; if(empty($size)) { echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>"; } else { $r = count($size); for($i=0; $i < $r; $i++) { echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n"; } } if ($show_form === false){ // Grab the form vars $Pic = $_POST['pic'] ; $Size = $_POST['size'] ; $Email = $_POST['email']; $Name = $_POST['first'. 'last']; $Addr = $_POST['addr']; $City = $_POST['city']; $State = $_POST['state']; $Zip = $_POST['zip']; $comments = $_POST['comments'] ; //message body $mail_body .= "$Pic"."\r\n"; $mail_body .= "$Size"."\r\n"; $mail_body .= "$Email"."\r\n"; $mail_body .= "$Name"."\r\n"; $mail_body .= "$Addr"."\r\n"; $mail_body .= "$City,". " $State". " $Zip"."\r\n"; $mail_body .= "$Comments"."\r\n"; //sending to $recipient = "hakarune@gmail.com"; $subject = "Order Form"; //Headerfields $header = "From: " . $Email . " <" . $Email . ">\r\n"; //mail command mail($recipient, $subject, $mail_body, $header); echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in 10 seconds...</div>"; //page redirect to home echo "<META HTTP-EQUIV=\"refresh\" content=\"10;URL=buttontest3.php\">"; } } if (true == $show_form) { ?> <form name="ordering" action="" method="POST"> <img src="1.jpg" /> <input type="checkbox" name="pic[]" value="1"> <br /> <select name="Type" size="1" name="size[]"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <img src="2.jpg" /> <input type="checkbox" name="pic[]" value="2"> <br /> <select name="Type" size="1" name="size[]"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <img src="3.jpg" /> <input type="checkbox" name="pic[]" Value="3"> <br /> <select name="Type" size="1" name="size[]"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <img src="4.jpg" /> <input type="checkbox" name="pic[]" value="4"> <br /> <select name="Type" size="1" name="size[]"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <img src="5.jpg" /> <input type="checkbox" name="pic[]" value="5"> <br /> <select name="Type" size="1" name="size[]"> <option value="">Select Type</option> <option value="Original">Original $Price</option> <option value="Print Small">300x500 Print $Price</option> <option value="Print Medium">800x600 Print $Price</option> <option value="Print Large">1200x1280 Print $Price</option> <option value="Print XLarge">1282x1400 Print $Price</option> </select> <br /> <br /> <br /> Information For Invoice: <font color="red">(Required Info = *)</font> <br /> <input type="text" name="first" Value="First Name" size="25" onfocus="value=''"><font color="red">*</font> <input type="text" name="last" Value="Last Name" size="25" onfocus="value=''"><font color="red">*</font> <br /> <input type="text" name="phone" Value="phone Number" size="25" onfocus="value=''"> <br /> <input type="text" name="email" Value="E-mail" size="30" onfocus="value=''"> <br /> <input type="text" name="addr" Value="Street Address" size="50" onfocus="value=''"><font color="red">*</font> <br /> <input type="text" name="city" Value="city" size="30" onfocus="value=''"><font color="red">*</font> <br /> <select name="state" size="1"> <option value="">Select State</option> <option value="AK">AK</option> <option value="AL">AL</option> <option value="AR">AR</option> <option value="AZ">AZ</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DC">DC</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="IA">IA</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="MA">MA</option> <option value="MD">MD</option> <option value="ME">ME</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MO">MO</option> <option value="MS">MS</option> <option value="MT">MT</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="NE">NE</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NV">NV</option> <option value="NY">NY</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VA">VA</option> <option value="VT">VT</option> <option value="WA">WA</option> <option value="WI">WI</option> <option value="WV">WV</option> <option value="WY">WY</option> </select> <br /> <input type="text" name="zip" Value="Zipcode" size="5" onfocus="value=''"><font color="red">*</font> <br /> <textarea name="comments" rows="5" cols="20" value="comments" onfocus="value=''"> </textarea> <br /> <input type="Submit" value="Submit"> <input type="reset" value="Clear Form"> </form> <?php }//true == $show_form ?> </body> </html> 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 |