Jump to content

please help me with php program

Predator50
Go to solution Solved by Yemto,

Your problem is your if statements, first you would need to use == or === instead of =, and then the variable should be $selected_radio and not $operation

https://dl.dropboxusercontent.com/u/4506031/Temp/try2.php

Please help me with this simple program,

when i select the full payment radio button, it will always process the partial option.

 

Thanks

try1.php

try2.php

Rig: CPU: Intel I7 4790k @ 4.5 ghz | MOBO: MSI Z97 Gaming 3 | RAM: 4x4 gigs Kingston Fury 1600 ddr3 | GPU: MSI Geforce GTX 1070 Gaming X PSU: Seasonic M12ii-620 Evo Edition | HDD: 1 TB WD, 500 GB WD | SSD: Kingston SSD now 240 and 120 GB CASE: In Win 303 RGB edition | Mouse: Corsair m65 pro | Keyboard: Roccat Ryos MK | Headset: Hyper X Cloud Pro  | Monitor: LG 29um58-P Ultrawide monitor.

 

Link to comment
Share on other sites

Link to post
Share on other sites

try

<html><body><?PHP	   if (isset($_POST['submit'])) {         $selected_radio = $_POST["operation"];         if ($selected_radio == "installment") 			 {				 //computation				$SubTotal = $_POST["price1"] + $_POST["price2"] + $_POST["price3"] + $_POST["price4"];                	$TotalUnit = $_POST["unit1"] + $_POST["unit2"] + $_POST["unit3"] + $_POST["unit4"];				$downpayment = ($TotalUnit * 920) + 4000;				$Fullprice = $SubTotal + 4000;				$PerSemPrice = $Fullprice - $downpayment;								//display				echo "Subtotal: " . $SubTotal . "<br/>";				echo "Mics:    4000" . "<br/>";				echo "Full Price: " . $Fullprice . "<br/>";				echo "Downpayment: " . $downpayment . "<br/>";				echo "Per Semestral price" . $PerSemPrice;				          }else if 		  ($selected_radio == "fullpayment") {			//computation			  $SubTotal = $_POST["price1"] + $_POST["price2"] + $_POST["price3"] + $_POST["price4"];               $TotalUnit = $_POST["unit1"] + $_POST["unit2"] + $_POST["unit3"] + $_POST["unit4"];			  $Discountprice = $TotalUnit * 800;			  $Fullpayment = ($SubTotal - $Discountprice ) + 4000;			  			  //display			  echo "Subtotal: " . $SubTotal . "<br />";			  echo "Mics:    4000" . "<br/>";			  echo "Discounted Price: " . $Discountprice . "<br />";			  echo "Full Payment Price: " . $Fullpayment;  			  			  		   }	}?></body></html>

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

 

try

<html><body><?PHP	   if (isset($_POST['submit'])) {         $selected_radio = $_POST["operation"];         if ($selected_radio == "installment") 			 {				 //computation				$SubTotal = $_POST["price1"] + $_POST["price2"] + $_POST["price3"] + $_POST["price4"];                	$TotalUnit = $_POST["unit1"] + $_POST["unit2"] + $_POST["unit3"] + $_POST["unit4"];				$downpayment = ($TotalUnit * 920) + 4000;				$Fullprice = $SubTotal + 4000;				$PerSemPrice = $Fullprice - $downpayment;								//display				echo "Subtotal: " . $SubTotal . "<br/>";				echo "Mics:    4000" . "<br/>";				echo "Full Price: " . $Fullprice . "<br/>";				echo "Downpayment: " . $downpayment . "<br/>";				echo "Per Semestral price" . $PerSemPrice;				          }else if 		  ($selected_radio == "fullpayment") {			//computation			  $SubTotal = $_POST["price1"] + $_POST["price2"] + $_POST["price3"] + $_POST["price4"];               $TotalUnit = $_POST["unit1"] + $_POST["unit2"] + $_POST["unit3"] + $_POST["unit4"];			  $Discountprice = $TotalUnit * 800;			  $Fullpayment = ($SubTotal - $Discountprice ) + 4000;			  			  //display			  echo "Subtotal: " . $SubTotal . "<br />";			  echo "Mics:    4000" . "<br/>";			  echo "Discounted Price: " . $Discountprice . "<br />";			  echo "Full Payment Price: " . $Fullpayment;  			  			  		   }	}?></body></html>

undefined variable.

Rig: CPU: Intel I7 4790k @ 4.5 ghz | MOBO: MSI Z97 Gaming 3 | RAM: 4x4 gigs Kingston Fury 1600 ddr3 | GPU: MSI Geforce GTX 1070 Gaming X PSU: Seasonic M12ii-620 Evo Edition | HDD: 1 TB WD, 500 GB WD | SSD: Kingston SSD now 240 and 120 GB CASE: In Win 303 RGB edition | Mouse: Corsair m65 pro | Keyboard: Roccat Ryos MK | Headset: Hyper X Cloud Pro  | Monitor: LG 29um58-P Ultrawide monitor.

 

Link to comment
Share on other sites

Link to post
Share on other sites

undefined variable.

which line? on chrome os so hard to test.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

which line? on chrome os so hard to test.

Notice: Undefined variable: operation in D:\xampp\htdocs\Thesis\try2.php on line 6

Notice: Undefined variable: operation in D:\xampp\htdocs\Thesis\try2.php on line 23

 

but it will display if the i just leave line 23 un edited but will display the error message.

 

Notice: Undefined variable: operation in D:\xampp\htdocs\Thesis\try2.php on line 6

Subtotal: 17200

Mics: 4000

Discounted Price: 12800

Full Payment Price: 8400

 

$operation == "installment") 

{
//computation
$SubTotal = $_POST["price1"] + $_POST["price2"] + $_POST["price3"] + $_POST["price4"]; 
                $TotalUnit = $_POST["unit1"] + $_POST["unit2"] + $_POST["unit3"] + $_POST["unit4"];
$downpayment = ($TotalUnit * 920) + 4000;
$Fullprice = $SubTotal + 4000;
$PerSemPrice = $Fullprice - $downpayment;
 
//display
echo "Subtotal: " . $SubTotal . "<br/>";
echo "Mics:    4000" . "<br/>";
echo "Full Price: " . $Fullprice . "<br/>";
echo "Downpayment: " . $downpayment . "<br/>";
echo "Per Semestral price" . $PerSemPrice;
 
          }else if 
 ($operation = "fullpayment") {

Rig: CPU: Intel I7 4790k @ 4.5 ghz | MOBO: MSI Z97 Gaming 3 | RAM: 4x4 gigs Kingston Fury 1600 ddr3 | GPU: MSI Geforce GTX 1070 Gaming X PSU: Seasonic M12ii-620 Evo Edition | HDD: 1 TB WD, 500 GB WD | SSD: Kingston SSD now 240 and 120 GB CASE: In Win 303 RGB edition | Mouse: Corsair m65 pro | Keyboard: Roccat Ryos MK | Headset: Hyper X Cloud Pro  | Monitor: LG 29um58-P Ultrawide monitor.

 

Link to comment
Share on other sites

Link to post
Share on other sites

thanks, it's working perfectly now.

Rig: CPU: Intel I7 4790k @ 4.5 ghz | MOBO: MSI Z97 Gaming 3 | RAM: 4x4 gigs Kingston Fury 1600 ddr3 | GPU: MSI Geforce GTX 1070 Gaming X PSU: Seasonic M12ii-620 Evo Edition | HDD: 1 TB WD, 500 GB WD | SSD: Kingston SSD now 240 and 120 GB CASE: In Win 303 RGB edition | Mouse: Corsair m65 pro | Keyboard: Roccat Ryos MK | Headset: Hyper X Cloud Pro  | Monitor: LG 29um58-P Ultrawide monitor.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×