Jump to content

[SOLVED] Adding Two Totals Together


nosher

Recommended Posts

Dear All ,

 

I am a complete beginner with PHP and would love some help with this issue if possible? We had a calculator made for us by someone who has now left the country, so no way of contacting him.

I have had some issues I posted another issue regarding the echo error code which ‘Friedemann Bach’ was able to resolve (Thanks Again)  ;D

 

On our Sale & Purchase form the totals display fine, but, I can’t get his grand total figure to work on the bottom.

 

This is the original code that the guy has left me so you can see it untouched, I have since modified all this to display better.

 

<?php
$errors=0;
$error="The following errors occured while processing your Quotation.<ul>";
if($electric==""){$errors=1;
$error.="<li>You did not enter a Property Price. Please go back and try again.<BR><BR>";
}
if($errors==1) echo $error;
if ($electric >= 0 and $electric <=65000)  { echo "<strong>our area</strong><BR><BR><strong>Purchasing Estimate</strong><BR><BR>Local Search £140<BR>
Our Fees £464.13 inc VAT <BR>
Land Registry Fees £60<BR>
Environmental search £34.08<BR>
Local registry search £4.00<BR>
Bankruptcy search £2.00<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Stamp duty land transaction return £58.75 inc VAT<BR><BR>
Total = £"; echo $electric * 0 /100 + 464.13 + 60 +274.25;}
if ($price >= 0 and $price <=65000)  { echo "<strong><BR><BR>Sales Estimate</strong>  
<BR><BR>Our Fees £464.13 inc VAT <BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Office Copy Entries £8.00 inc VAT<BR><BR>
Total = $t2£"; echo  + 464.13 +43.25;}


if ($electric >= 65001 and $electric <=85000)  { echo " <strong>our area</strong><BR><BR><strong>Purchasing Estimate</strong><BR><BR>Local Search £140<BR>
Our Fees £499.38 inc VAT<BR>
Land Registry Fees £60<BR>
Environmental search £34.08<BR>
Local registry search £4.00<BR>
Bankruptcy search £2.00<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Stamp duty land transaction return £58.75 inc VAT<BR><BR>
Total =  $t2£"; echo $electric * 0 /100 + 499.38 + 60 +274.25;}


if ($electric >= 85001 and $electric <=110000)  { echo "<strong>our area</strong><BR><BR><strong>Purchasing Estimate</strong><BR><BR>Local Search £140<BR>
Our Fees £499.38 inc VAT<BR>
Land Registry Fees £100<BR>
Environmental search £34.08<BR>
Local registry search £4.00<BR>
Bankruptcy search £2.00<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Stamp duty land transaction return £58.75 inc VAT<BR><BR>
Total = $t2£";  echo $electric * 0 /100 + 528.75 + 100 +274.25;}

if ($electric >= 110001 and $electric <=119999)  { echo "<strong>our area</strong><BR><BR><strong>Purchasing Estimate</strong><BR><BR>Local Search £140<BR>
Our Fees £499.38 inc VAT<BR>
Land Registry Fees £100<BR>
Environmental search £34.08<BR>
Local registry search £4.00<BR>
Bankruptcy search £2.00<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Stamp duty land transaction return £58.75 inc VAT<BR><BR>
Total = $t2£";  echo $electric * 0 /100 + 528.75 + 100 +274.25;}

if ($electric >= 120000 and $electric <=150000)  { echo "<strong>our area</strong><BR><BR><strong>Purchasing Estimate</strong><BR><BR>Local Search £140<BR>
Our Fees £558.13 inc VAT<BR>
Land Registry Fees £150<BR>
Environmental search £34.08<BR>
Local registry search £4.00<BR>
Bankruptcy search £2.00<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Stamp duty land transaction return £58.75 inc VAT<BR>
Stamp Duty £";  echo $electric * 1 /100;}
if ($electric >= 120000 and $electric <=150000)  { echo "<BR><BR> Total = $t2£"; echo $electric * 1 /100 + 558.13 + 150 +274.25;}

if ($electric >= 150001 and $electric <=200000)  { echo "<strong>our area</strong><BR><BR><strong>Purchasing Estimate</strong><BR><BR>Local Search £140<BR>
Our Fees £581.63 inc VAT<BR>
Land Registry Fees £150<BR>
Environmental search £34.08<BR>
Local registry search £4.00<BR>
Bankruptcy search £2.00<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Stamp duty land transaction return £58.75 inc VAT<BR>
Stamp Duty  £"; echo $electric * 1 /100;} 
if ($electric >= 150001 and $electric <=200000)  { echo "<BR><BR> Total = $t2£"; echo $electric * 1 /100 + 581.63 + 150 +274.25;}


if ($electric >= 200001 and $electric <=250000)  { echo "<strong>our area</strong><BR><BR><strong>Purchasing Estimate</strong><BR><BR>Local Search £140<BR>
Our Fees £616.87 inc VAT<BR>
Land Registry Fees £220<BR>
Environmental search £34.08<BR>
Local registry search £4.00<BR>
Bankruptcy search £2.00<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Stamp duty land transaction return £58.75 inc VAT<BR>
Stamp Duty  £"; echo $electric * 1 /100;}
if ($electric >= 200001 and $electric <=250000)  { echo "<BR><BR>Total = $t2£"; echo $electric * 1 /100 + 616.87 + 220 +274.25;}

if ($electric >= 250001 and $electric <=300000)  { echo "<strong>our area</strong><BR><BR><strong>Purchasing Estimate</strong><BR><BR>Local Search £140<BR>
Our Fees £675.62 inc VAT<BR>
Land Registry Fees £220<BR>
Environmental search £34.08<BR>
Local registry search £4.00<BR>
Bankruptcy search £2.00<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Stamp duty land transaction return £58.75 inc VAT<BR>
Stamp Duty  £"; echo $electric * 3 /100;}
if ($electric >= 250001 and $electric <=300000)  { echo "<BR><BR>Total = $t2£"; echo $electric * 3 /100 + 675.62 + 220 +274.25;}




if ($price >= 65001 and $price <=85000)  { echo "<strong><BR><BR>Sales Estimate</strong> 
<BR><BR>Our Fees £499.38 inc VAT<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Office Copy Entries £8.00 inc VAT<BR><BR>
Total =  $t1£"; echo  + 499.38  +43.25;}


if ($price >= 85001 and $price <=110000)  { echo "<strong><BR><BR>Sales Estimate</strong>    
<BR><BR>Our Fees £499.38 inc VAT<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Office Copy Entries £8.00 inc VAT<BR><BR>
Total = $t1£";  echo   + 528.75 +43.25;}

if ($price >= 110001 and $price <=119999)  { echo "<strong><BR><BR>Sales Estimate</strong> 
<BR><BR>Our Fees £499.38 inc VAT<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Office Copy Entries £8.00 inc VAT<BR><BR>
Total = $t1£";  echo  + 528.75  +43.25;}

if ($price >= 120000 and $price <=150000)  { echo "<strong><BR><BR>Sales Estimate</strong>   
<BR><BR>Our Fees £558.13 inc VAT<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Office Copy Entries £8.00 inc VAT<BR><BR>
Total = $t1£"; echo  + 558.13  +43.25;}

if ($price >= 150001 and $price <=200000)  { echo "<strong><BR><BR>Sales Estimate</strong>  
<BR><BR>Our Fees £581.63 inc VAT<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Office Copy Entries £8.00 inc VAT<BR><BR>
Total = $t1£"; echo  + 581.63  +43.25;}


if ($price >= 200001 and $price <=250000)  { echo "<strong><BR><BR>Sales Estimate</strong> 
<BR><BR>Our Fees £616.87 inc VAT<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Office Copy Entries £8.00 inc VAT<BR><BR>
Total = $t1£"; echo  + 616.87  +43.25;}

if ($price >= 250001 and $price <=300000)  { echo "<strong><BR><BR>Sales Estimate</strong> 
<BR><BR>Our Fees £675.62 inc VAT<BR>
Telegraphic Transfer Fee £35.25 inc VAT<BR>
Office Copy Entries £8.00 inc VAT<BR><BR>
Total = $t1£"; echo + 675.62 +43.25;}

//if ($electric >= 0 and $electric <=65000)  { echo "<BR><BR><strong>Grand Total = </strong>£"; echo $electric * 0 /100 + 464.13 + 60 +274.25 +($price >= 65001 and $price <=85000) +499.38 +43.25;}
//if ($electric >= 65001 and $electric <=85000)  { echo "<BR><BR><strong>Grand Total = </strong> £"; echo $electric * 0 /100 + 499.38 + 60 +274.25 +($price >= 85001 and $price <=110000)+ 499.38  +43.25;}
//if ($electric >= 85001 and $electric <=110000)  { echo "<BR><BR><strong>Grand Total = </strong>£"; echo $electric * 0 /100 + 528.75 + 100 +274.25 +($price >= 110001 and $price <=119999) + 528.75  +43.25;}
//if ($electric >= 110001 and $electric <=119999)  { echo "<BR><BR><strong>Grand Total = </strong>£"; echo $electric * 0 /100 + 528.75 + 100 +274.25 + ($price >= 110001 and $price <=119999) + 528.75  +43.25;}
//if ($electric >= 120000 and $electric <=150000)  { echo "<BR><BR><strong>Grand Total = </strong>£";echo $electric * 1 /100 + 558.13 + 150 +274.25 +($price >= 120000 and $price <=150000) + 558.13  +43.25;}
//if ($electric >= 150001 and $electric <=200000)  { echo "<BR><BR><strong>Grand Total = </strong>£"; echo $electric * 1 /100 + 581.63 + 150 +274.25 +($price >= 150001 and $price <=200000) + 581.63  +43.25;}
//if ($electric >= 200001 and $electric <=250000)  { echo "<BR><BR><strong>Grand Total = </strong>£"; echo $electric * 1 /100 + 616.87 + 220 +274.25 +($price >= 200001 and $price <=250000) + 616.87  +43.25;}
//if ($electric >= 250001 and $electric <=300000)  { echo "<BR><BR><strong>Grand Total = </strong>£"; echo $electric * 3 /100 + 675.62 + 220 +274.25 +($price >= 250001 and $price <=300000) + 675.62 +43.25;}
{?>





<BR><BR>If you are happy with our Estimate please fill in this form and we will contact you shortly  <A href="/ll/request/form1.html">Click Here</A>


<?php 
}
?>

 

Many Thanks for any help with this

 

Nosher :)

Link to comment
Share on other sites

Ok I will say this, the code you have there is

 

1. Dire

2. Incomplete

3. Very repetitive

 

I have tidied this code up as best I can,

 

<?php
//Declare error catching variables
$error_no = 0;
$error_str = "The following errors occured while processing your Quotation.<br /><br />";

// Sales estimate variables
$sales_est = "";
$sales_ofee = 0.00;
$sales_ttfee = 35.25;
$sales_ocentries = 8.00;
$sales_total = 0.00;

// Purchase estimate variables
// Estimate string
$purchase_est = "";
// Local search
$purchase_lsearch = 140;
// Our fee
$purchase_ofee = 0.00;
// Land registry fee
$purchase_lrfee = 60.00;
// Environmental search
$purchase_esearch = 34.08;
// Local registry search
$purchase_lrsearch = 4.00;
// Bankruptcy search
$purchase_bsearch = 2.00;
// Telegraphic transfer fee
$purchase_ttfee = 35.25;
// Stamp duty land transaction return
$purchase_sdltr = 58.75;
// Total of purchase estimate
$purchase_total = 0.00;
//Unknown figure of 274.25 from original script
$purchase_unknown = 274.25;
//Purchase divider
$purchase_divider = 0;

// Check for invalid null value
if($electric===Null) { 
$error_no = 1;
$error_str .= "You did not enter a Property Price. Please go back && try again.<br /><br />";
}

// Return error message
if($error_no===1) {
echo $error_str;
}

/** PURCHASE ESTIMATES **/
if (($electric >= 0) && ($electric <= 65000))  {	
$purchase_ofee = 464.13;
}

if (($electric >= 65001) && ($electric <=85000))  {	
$purchase_ofee = 499.38;
}


if (($electric >= 85001) && ($electric <=119999))  {	
$purchase_ofee = 499.38;
$purchase_lrfee = 100;
}

if (($electric >= 120000) && ($electric <=150000))  {	
$purchase_ofee = 558.13;
$purchase_lrfee = 150;
$purchase_divider = 1;
}

if (($electric >= 150001) && ($electric <=200000))  {	
$purchase_ofee = 581.63;
$purchase_lrfee = 150;
$purchase_divider = 1;	
} 

if (($electric >= 200001) && ($electric <=250000))  {	
$purchase_ofee = 616.87;
$purchase_lrfee = 220;
$purchase_divider = 1;
}

if (($electric >= 250001) && ($electric <=300000))  {	
$purchase_ofee = 675.62;
$purchase_lrfee = 220;
$purchase_divider = 3;
}

$purchase_total = ($electric * $purchase_divider / 100) + $purchase_ofee + $purchase_lrfee + $purchase_unknown;

$purchase_est = "<strong>our area</strong>
<br />
<br />
<strong>Purchasing Estimate</strong>
<br /><br />Local Search £{$purchase_lsearch}
<br />
Our Fees £{$purchase_ofee} inc VAT
<br />
Land Registry Fees £{$purchase_lrfee}
<br />
Environmental search £{$purchase_esearch}
<br />
Local registry search £{$purchase_lrsearch}
<br />
Bankruptcy search £{$purchase_bsearch}
<br />
Telegraphic Transfer Fee £{$purchase_ttfee} inc VAT
<br />
Stamp duty land transaction return £{$purchase_sdltr} inc VAT
<br />
Total = £{$purchase_total}"; 


/***** SALES ESTIMATES *****/

if (($price >= 0) && ($price <=65000))  {	
$sales_ofee = 464.13;
}

if (($price >= 65001) && ($price <= 119999))  { 
$sales_ofee = 499.38;
}

if (($price >= 120000) && ($price <=150000))  { 
$sales_ofee = 558.13;
}

if (($price >= 150001) && ($price <=200000))  { 
$sales_ofee = 581.63;
} 

if (($price >= 200001) && ($price <=250000))  { 
$sales_ofee = 616.87;
}

if (($price >= 250001) && ($price <=300000))  { 
$sales_ofee = 675.62;
}

$sales_total = $sales_ofee + $sales_ttfee + $sales_ocentries;

$sales_est = "<br />
<br />
<strong>Sales Estimate</strong>
<br/>
<br />
Our Fees £{$sales_ofee} inc VAT
<br />
Telegraphic Transfer Fee £ {$sales_ttfee} inc VAT
<br />
Office Copy Entries £{$sales_ocentries} inc VAT
<br />
<br />
Total = {$sales_total}";

?>

 

I have left in the rather odd error trapping you have at the top as I assume it must affect something elsewhere in your script but I changed the names because $errors and $error are too close for comfort in likeness.

 

You also had a $t2£ variable that is not set anywhere so I removed it. The $electric and $price variables are not set anywhere either so I have left them as is.

 

Your code also created several if statements for the same output, and in some cases the same evaluations, very bizarre.

 

Hopefully you can read and understand what I have done.

Link to comment
Share on other sites

Thank you so much for replying to me and amending this code, ;D

 

Unfortunately the results are not being displayed I just get a blank page >:( after the calculation any idea? What I am doing wrong here

 

I have just saved your code as the new page

 

Many Thanks

 

Nosher

 

Link to comment
Share on other sites

You will get a blank page, my clean up is not outputting anything to the browser :)

 

First you need to get your hands dirty and assign a value to,

 

$price

$electric

 

As I mentioned these are not set in your original script anywhere so I do not know where they come from but they seem to be the triggers behind the rest of your code. They must come from somewhere so do you have another script?

 

Again the error trapping that you have is something custom, I don't really know what affect there would be on removing it from your site (although I have changed the names) but that is something you need to decide.

Link to comment
Share on other sites

Thanks for your help on this but as I mentioned before I am very new to PHP and know basically nothing, my firm paid some guy to develop this calculator, so I am trying to help them out as best as I can to resolve some issues :-[

 

The calculator is working but it just doesn’t display the grand total at the bottom of the page.

Our calculator is setup as follows: 

Purchase – HTML, form post (electric)
Purchase.php,  results page


Sale – HTML, form post (price)
Sale.php, - results page


Sale & Purchase – HTML, form post (electric, price)
Sp.php, - for results page

 

 

He has then just put the purchase & sale results on the same page which display both balances correctly but it doesn’t add up both figures for purchase & sale and display the grand total

 

Sorry to muck you about with this but Its way out of my depth

 

Nosher

 

Link to comment
Share on other sites

purchase HTML Form

 

<form method="get" action="purchase.php">
<BODY>
<table width='50%' border=0>
<FONT SIZE=2><FONT FACE="Verdana"><strong></strong><BR><BR> 
<FONT SIZE=2><FONT FACE="Verdana"></FONT><BR><BR> 
<BR><BR>

£<input type=text name='electric'></td></tr>
<input type="submit" name="Submit" value="Submit"><BR><BR>
</form>

 

Sale HTML Form

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
<TITLE></TITLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<FORM ACTION="sale.php">
<P><FONT SIZE=2><FONT FACE="Verdana"><BR><BR></FONT><BR><BR>£<INPUT TYPE=TEXT NAME="price" SIZE=20>
<INPUT TYPE=SUBMIT NAME="Submit" VALUE="Calculate"><BR><BR></FONT>
</P>
</FORM>
</BODY>
</HTML>

Sale & Purchase HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
<TITLE></TITLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<P STYLE="margin-bottom: 0cm"><FONT SIZE=2 FACE="Verdana"> </FONT></P>
<FORM ACTION="sp.php">
<TABLE WIDTH=50% BORDER=0 CELLPADDING=2 CELLSPACING=2>
<TR>
<TD>
<P><STRONG>Purchase Price</STRONG></P>
</TD>
<TD>
<P><STRONG>£</STRONG><INPUT TYPE=TEXT NAME="electric" SIZE=20></P>
</TD>
</TR>
<TR>
<TD>
<P><STRONG>Sale Price</STRONG></P>
</TD>
<TD>
<P><STRONG>£</STRONG><INPUT TYPE=TEXT NAME="price" SIZE=20></P>
</TD>
</TR>
<TR>
<TD>
<P><INPUT TYPE=SUBMIT NAME="Submit" VALUE="Calculate"></P>
</TD>
<TD VALIGN=TOP></TD>
</TR>
</TABLE>
</FORM>
<P><BR><BR>
</P>
</BODY>
</HTML>

 

Hope this helps

 

Many Many Thanks

 

Nosher

Link to comment
Share on other sites

Try copying this into a file called calculate.php then point a web browser to it and see if it works :)

 

<?php

$is_start = true;
$html = "";

if (isset($_POST['purchase'])) {

//Read in and validate the post purchase
$electric = (int)htmlentities($_POST['purchase'], ENT_QUOTES);

// Purchase estimate variables
// Local search
$purchase_lsearch = 140;
// Our fee
$purchase_ofee = 0.00;
// Land registry fee
$purchase_lrfee = 60.00;
// Environmental search
$purchase_esearch = 34.08;
// Local registry search
$purchase_lrsearch = 4.00;
// Bankruptcy search
$purchase_bsearch = 2.00;
// Telegraphic transfer fee
$purchase_ttfee = 35.25;
// Stamp duty land transaction return
$purchase_sdltr = 58.75;
// Total of purchase estimate
$purchase_total = 0.00;
//Unknown figure of 274.25 from original script
$purchase_unknown = 274.25;
//Purchase divider
$purchase_divider = 0;


/** PURCHASE ESTIMATES **/
if (($electric >= 0) && ($electric <= 65000))  {	
	$purchase_ofee = 464.13;
}

if (($electric >= 65001) && ($electric <=85000))  {	
	$purchase_ofee = 499.38;
}


if (($electric >= 85001) && ($electric <=119999))  {	
	$purchase_ofee = 499.38;
	$purchase_lrfee = 100;
}

if (($electric >= 120000) && ($electric <=150000))  {	
	$purchase_ofee = 558.13;
	$purchase_lrfee = 150;
	$purchase_divider = 1;
}

if (($electric >= 150001) && ($electric <=200000))  {	
	$purchase_ofee = 581.63;
	$purchase_lrfee = 150;
	$purchase_divider = 1;	
} 

if (($electric >= 200001) && ($electric <=250000))  {	
	$purchase_ofee = 616.87;
	$purchase_lrfee = 220;
	$purchase_divider = 1;
}

if (($electric >= 250001) && ($electric <=300000))  {	
	$purchase_ofee = 675.62;
	$purchase_lrfee = 220;
	$purchase_divider = 3;
}

$purchase_total = ($electric * $purchase_divider / 100) + $purchase_ofee + $purchase_lrfee + $purchase_unknown;

$purchase_est = "Our area
<br />
<br />
Purchasing Estimate
<br />
<br />Local Search £{$purchase_lsearch}
<br />
Our Fees £{$purchase_ofee} inc VAT
<br />
Land Registry Fees £{$purchase_lrfee}
<br />
Environmental search £{$purchase_esearch}
<br />
Local registry search £{$purchase_lrsearch}
<br />
Bankruptcy search £{$purchase_bsearch}
<br />
Telegraphic Transfer Fee £{$purchase_ttfee} inc VAT
<br />
Stamp duty land transaction return £{$purchase_sdltr} inc VAT
<br />
Total = £{$purchase_total}";

$is_start = false;

} else {
$purchase_est = "";
}

if (isset($_POST['sales'])) {

//Read in and validate the post purchase
$price = (int)htmlentities($_POST['sales'], ENT_QUOTES);	

// Sales estimate variables
// Our fee
$sales_ofee = 0.00;
// Telegraphic transfer fee
$sales_ttfee = 35.25;
// Out copy entries
$sales_ocentries = 8.00;
// Sales total
$sales_total = 0.00;

/***** SALES ESTIMATES *****/

if (($price >= 0) && ($price <=65000))  {	
	$sales_ofee = 464.13;
}

if (($price >= 65001) && ($price <= 119999))  { 
	$sales_ofee = 499.38;
}

if (($price >= 120000) && ($price <=150000))  { 
	$sales_ofee = 558.13;
}

if (($price >= 150001) && ($price <=200000))  { 
	$sales_ofee = 581.63;
} 

if (($price >= 200001) && ($price <=250000))  { 
	$sales_ofee = 616.87;
}

if (($price >= 250001) && ($price <=300000))  { 
	$sales_ofee = 675.62;
}

$sales_total = $sales_ofee + $sales_ttfee + $sales_ocentries;

$sales_est = "<br />
<br />
Sales Estimate
<br />
<br />
Our Fees £{$sales_ofee} inc VAT
<br />
Telegraphic Transfer Fee £ {$sales_ttfee} inc VAT
<br />
Office Copy Entries £{$sales_ocentries} inc VAT
<br />
<br />
Total = {$sales_total}";

$is_start = false;
} else {
$sales_est = "";
}

if ($is_start===true) {

$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Calculator</title>
</head>
<body>
<form method='post' action='calculate.php'>
Purchase price
<br />
£<input name='purchase' type='text' value='0' size='20' />
<br />
<br />
Sales price
<br />
£<input name='sales' type='text' value='0' size='20' />
<br />
<br />
<input name='calc' type='submit' value='Calculate' />
</form>
</body>
</html>";

} else {

$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Calculator</title>
</head>
<body>
$purchase_est
<br />
<br />
$sales_est
</body>
</html>";

}

echo $html;
?>

Link to comment
Share on other sites

Try this,

 

<?php

$is_start = true;
$html = "";
$total = 0;

if (isset($_POST['purchase'])) {

//Read in and validate the post purchase
$electric = (int)htmlentities($_POST['purchase'], ENT_QUOTES);

// Purchase estimate variables
// Local search
$purchase_lsearch = 140;
// Our fee
$purchase_ofee = 0.00;
// Land registry fee
$purchase_lrfee = 60.00;
// Environmental search
$purchase_esearch = 34.08;
// Local registry search
$purchase_lrsearch = 4.00;
// Bankruptcy search
$purchase_bsearch = 2.00;
// Telegraphic transfer fee
$purchase_ttfee = 35.25;
// Stamp duty land transaction return
$purchase_sdltr = 58.75;
// Total of purchase estimate
$purchase_total = 0.00;
//Unknown figure of 274.25 from original script
$purchase_unknown = 274.25;
//Purchase divider
$purchase_divider = 0;


/** PURCHASE ESTIMATES **/
if (($electric >= 0) && ($electric <= 65000))  {	
	$purchase_ofee = 464.13;
}

if (($electric >= 65001) && ($electric <=85000))  {	
	$purchase_ofee = 499.38;
}


if (($electric >= 85001) && ($electric <=119999))  {	
	$purchase_ofee = 499.38;
	$purchase_lrfee = 100;
}

if (($electric >= 120000) && ($electric <=150000))  {	
	$purchase_ofee = 558.13;
	$purchase_lrfee = 150;
	$purchase_divider = 1;
}

if (($electric >= 150001) && ($electric <=200000))  {	
	$purchase_ofee = 581.63;
	$purchase_lrfee = 150;
	$purchase_divider = 1;	
} 

if (($electric >= 200001) && ($electric <=250000))  {	
	$purchase_ofee = 616.87;
	$purchase_lrfee = 220;
	$purchase_divider = 1;
}

if (($electric >= 250001) && ($electric <=300000))  {	
	$purchase_ofee = 675.62;
	$purchase_lrfee = 220;
	$purchase_divider = 3;
}

$purchase_total = ($electric * $purchase_divider / 100) + $purchase_ofee + $purchase_lrfee + $purchase_unknown;

$purchase_est = "Our area
<br />
<br />
Purchasing Estimate
<br />
<br />Local Search £{$purchase_lsearch}
<br />
Our Fees £{$purchase_ofee} inc VAT
<br />
Land Registry Fees £{$purchase_lrfee}
<br />
Environmental search £{$purchase_esearch}
<br />
Local registry search £{$purchase_lrsearch}
<br />
Bankruptcy search £{$purchase_bsearch}
<br />
Telegraphic Transfer Fee £{$purchase_ttfee} inc VAT
<br />
Stamp duty land transaction return £{$purchase_sdltr} inc VAT
<br />
Total = £{$purchase_total}";

$is_start = false;
$total = $total + $purchase_total;

} else {
$purchase_est = "";
}

if (isset($_POST['sales'])) {

//Read in and validate the post purchase
$price = (int)htmlentities($_POST['sales'], ENT_QUOTES);	

// Sales estimate variables
// Our fee
$sales_ofee = 0.00;
// Telegraphic transfer fee
$sales_ttfee = 35.25;
// Out copy entries
$sales_ocentries = 8.00;
// Sales total
$sales_total = 0.00;

/***** SALES ESTIMATES *****/

if (($price >= 0) && ($price <=65000))  {	
	$sales_ofee = 464.13;
}

if (($price >= 65001) && ($price <= 119999))  { 
	$sales_ofee = 499.38;
}

if (($price >= 120000) && ($price <=150000))  { 
	$sales_ofee = 558.13;
}

if (($price >= 150001) && ($price <=200000))  { 
	$sales_ofee = 581.63;
} 

if (($price >= 200001) && ($price <=250000))  { 
	$sales_ofee = 616.87;
}

if (($price >= 250001) && ($price <=300000))  { 
	$sales_ofee = 675.62;
}

$sales_total = $sales_ofee + $sales_ttfee + $sales_ocentries;

$sales_est = "<br />
<br />
Sales Estimate
<br />
<br />
Our Fees £{$sales_ofee} inc VAT
<br />
Telegraphic Transfer Fee £ {$sales_ttfee} inc VAT
<br />
Office Copy Entries £{$sales_ocentries} inc VAT
<br />
<br />
Total = {$sales_total}";

$is_start = false;
$total = $total + $sales_total;

} else {
$sales_est = "";
}

if ($is_start===true) {

$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Calculator</title>
</head>
<body>
<form method='post' action='calculate.php'>
Purchase price
<br />
£<input name='purchase' type='text' value='0' size='20' />
<br />
<br />
Sales price
<br />
£<input name='sales' type='text' value='0' size='20' />
<br />
<br />
<input name='calc' type='submit' value='Calculate' />
</form>
</body>
</html>";

} else {

$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Calculator</title>
</head>
<body>
{$purchase_est}
<br />
<br />
{$sales_est}
<br />
<br />
Total: {$total}
</body>
</html>";

}

echo $html;
?>

Link to comment
Share on other sites

Cep,

 

That is fantastic - Thank You  ;D

 

I have just noticed that the Purchase divider, which is the (stamp duty), I need to get this to display the divider figure but its not

 

Sorry to be a pain, :-[ am trying to have a go myself in the mean time

 

Nosher

 

Link to comment
Share on other sites

I have tried this loads of different ways and failed! :(

at this moment in time I have added the Stamp Duty to display but to be honest with you I am just trying, lol

Nosher

 

<?php

$is_start = true;
$html = "";
$total = 0;

if (isset($_POST['purchase'])) {

//Read in and validate the post purchase
$electric = (int)htmlentities($_POST['purchase'], ENT_QUOTES);

// Purchase estimate variables
// Local search
$purchase_lsearch = 140;
// Our fee
$purchase_ofee = 0.00;
// Land registry fee
$purchase_lrfee = 60.00;
// Environmental search
$purchase_esearch = 34.08;
// Local registry search
$purchase_lrsearch = 4.00;
// Bankruptcy search
$purchase_bsearch = 2.00;
// Telegraphic transfer fee
$purchase_ttfee = 35.25;
// Stamp duty land transaction return
$purchase_sdltr = 58.75;
// Total of purchase estimate
$purchase_total = 0.00;
//Unknown figure of 274.25 from original script
$purchase_unknown = 274.25;
//Purchase divider
$purchase_divider = 0;


/** PURCHASE ESTIMATES **/
if (($electric >= 0) && ($electric <= 65000))  {	
	$purchase_ofee = 464.13;
}

if (($electric >= 65001) && ($electric <=85000))  {	
	$purchase_ofee = 499.38;
}


if (($electric >= 85001) && ($electric <=119999))  {	
	$purchase_ofee = 499.38;
	$purchase_lrfee = 100;
}

if (($electric >= 120000) && ($electric <=150000))  {	
	$purchase_ofee = 558.13;
	$purchase_lrfee = 150;
	$purchase_divider = 1;
}

if (($electric >= 150001) && ($electric <=200000))  {	
	$purchase_ofee = 581.63;
	$purchase_lrfee = 150;
	$purchase_divider = 1;	
} 

if (($electric >= 200001) && ($electric <=250000))  {	
	$purchase_ofee = 616.87;
	$purchase_lrfee = 220;
	$purchase_divider = 1;
}

if (($electric >= 250001) && ($electric <=300000))  {	
	$purchase_ofee = 675.62;
	$purchase_lrfee = 220;
	$purchase_divider = 3;
}

$purchase_total = ($electric * $purchase_divider / 100) + $purchase_ofee + $purchase_lrfee + $purchase_unknown;

$purchase_est = "Our area
<br />
<br />
Purchasing Estimate
<br />
<br />Local Search £{$purchase_lsearch}
<br />
Our Fees £{$purchase_ofee} inc VAT
<br />
Land Registry Fees £{$purchase_lrfee}
<br />
Environmental search £{$purchase_esearch}
<br />
Local registry search £{$purchase_lrsearch}
<br />
Bankruptcy search £{$purchase_bsearch}
<br />
Telegraphic Transfer Fee £{$purchase_ttfee} inc VAT
<br />
Stamp duty land transaction return £{$purchase_sdltr} inc VAT
<br />
Stamp duty £{$purchase_divider}
<br />
Total = £{$purchase_total}";

$is_start = false;
$total = $total + $purchase_total;

} else {
$purchase_est = "";
}

if (isset($_POST['sales'])) {

//Read in and validate the post purchase
$price = (int)htmlentities($_POST['sales'], ENT_QUOTES);	

// Sales estimate variables
// Our fee
$sales_ofee = 0.00;
// Telegraphic transfer fee
$sales_ttfee = 35.25;
// Out copy entries
$sales_ocentries = 8.00;
// Sales total
$sales_total = 0.00;

/***** SALES ESTIMATES *****/

if (($price >= 0) && ($price <=65000))  {	
	$sales_ofee = 464.13;
}

if (($price >= 65001) && ($price <= 119999))  { 
	$sales_ofee = 499.38;
}

if (($price >= 120000) && ($price <=150000))  { 
	$sales_ofee = 558.13;
}

if (($price >= 150001) && ($price <=200000))  { 
	$sales_ofee = 581.63;
} 

if (($price >= 200001) && ($price <=250000))  { 
	$sales_ofee = 616.87;
}

if (($price >= 250001) && ($price <=300000))  { 
	$sales_ofee = 675.62;
}

$sales_total = $sales_ofee + $sales_ttfee + $sales_ocentries;

$sales_est = "<br />
<br />
Sales Estimate
<br />
<br />
Our Fees £{$sales_ofee} inc VAT
<br />
Telegraphic Transfer Fee £ {$sales_ttfee} inc VAT
<br />
Office Copy Entries £{$sales_ocentries} inc VAT
<br />
<br />
Total = {$sales_total}";

$is_start = false;
$total = $total + $sales_total;

} else {
$sales_est = "";
}

if ($is_start===true) {

$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Calculator</title>
</head>
<body>
<form method='post' action='calculate.php'>
Purchase price
<br />
£<input name='purchase' type='text' value='0' size='20' />
<br />
<br />
Sales price
<br />
£<input name='sales' type='text' value='0' size='20' />
<br />
<br />
<input name='calc' type='submit' value='Calculate' />
</form>
</body>
</html>";

} else {

$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Calculator</title>
</head>
<body>
{$purchase_est}
<br />
<br />
{$sales_est}
<br />
<br />
Total: {$total}
</body>
</html>";

}

echo $html;
?>

Link to comment
Share on other sites

Yes I have Cep it just displays: £1 for the stamp duty

 

I just can’t seem to work out how to get the stamp duty to display the percentage.

On the old form he had this to display the stamp duty

 

 

Purchasing Estimate 

Local Search £140 
Our Fees £581.63 inc VAT 
Land Registry Fees £150 
Environmental search £34.08 
Local registry search £4 
Bankruptcy search £2 
Telegraphic Transfer Fee £35.25 inc VAT 
Stamp duty land transaction return £58.75 inc VAT 
Stamp duty £1 
Total = £2565.88 



Sales Estimate 

Our Fees £464.13 inc VAT 
Telegraphic Transfer Fee £ 35.25 inc VAT 
Office Copy Entries £8 inc VAT 

Total = 507.38 

Total: 3073.26 

Link to comment
Share on other sites

*******Sorry Cep forgot to add in this code below********

 

Yes I have Cep it just displays: £1 for the stamp duty

 

I just can’t seem to work out how to get the stamp duty to display the percentage.

On the old form he had this to display the stamp duty

 

Stamp Duty  £"; echo $electric * 1 /100;} 
if ($electric >= 150001 and $electric <=200000)  { echo "<BR><BR> Total = $t2£"; echo $electric * 1 /100 + 581.63 + 150 +274.25;}

 

Purchasing Estimate 

Local Search £140 
Our Fees £581.63 inc VAT 
Land Registry Fees £150 
Environmental search £34.08 
Local registry search £4 
Bankruptcy search £2 
Telegraphic Transfer Fee £35.25 inc VAT 
Stamp duty land transaction return £58.75 inc VAT 
Stamp duty £1 
Total = £2565.88 



Sales Estimate 

Our Fees £464.13 inc VAT 
Telegraphic Transfer Fee £ 35.25 inc VAT 
Office Copy Entries £8 inc VAT 

Total = 507.38 

Total: 3073.26 

 

Link to comment
Share on other sites

I see well then that is a simple assignment, this should work give it a try.

 

<?php

$is_start = true;
$html = "";
$total = 0;

if (isset($_POST['purchase'])) {

//Read in and validate the post purchase
$electric = (int)htmlentities($_POST['purchase'], ENT_QUOTES);

// Purchase estimate variables
// Local search
$purchase_lsearch = 140;
// Our fee
$purchase_ofee = 0.00;
// Land registry fee
$purchase_lrfee = 60.00;
// Environmental search
$purchase_esearch = 34.08;
// Local registry search
$purchase_lrsearch = 4.00;
// Bankruptcy search
$purchase_bsearch = 2.00;
// Telegraphic transfer fee
$purchase_ttfee = 35.25;
// Stamp duty land transaction return
$purchase_sdltr = 58.75;
// Total of purchase estimate
$purchase_total = 0.00;
//Unknown figure of 274.25 from original script
$purchase_unknown = 274.25;
//Purchase divider
$purchase_divider = 0;
//Stamp duty
$purchase_sduty = 0;


/** PURCHASE ESTIMATES **/
if (($electric >= 0) && ($electric <= 65000))  {	
	$purchase_ofee = 464.13;
}

if (($electric >= 65001) && ($electric <=85000))  {	
	$purchase_ofee = 499.38;
}


if (($electric >= 85001) && ($electric <=119999))  {	
	$purchase_ofee = 499.38;
	$purchase_lrfee = 100;
}

if (($electric >= 120000) && ($electric <=150000))  {	
	$purchase_ofee = 558.13;
	$purchase_lrfee = 150;
	$purchase_divider = 1;
}

if (($electric >= 150001) && ($electric <=200000))  {	
	$purchase_ofee = 581.63;
	$purchase_lrfee = 150;
	$purchase_divider = 1;	
} 

if (($electric >= 200001) && ($electric <=250000))  {	
	$purchase_ofee = 616.87;
	$purchase_lrfee = 220;
	$purchase_divider = 1;
}

if (($electric >= 250001) && ($electric <=300000))  {	
	$purchase_ofee = 675.62;
	$purchase_lrfee = 220;
	$purchase_divider = 3;
}

$purchase_sduty = $electric * ($purchase_divider / 100);
$purchase_total = ($electric * ($purchase_divider / 100)) + $purchase_ofee + $purchase_lrfee + $purchase_unknown;

$purchase_est = "Our area
<br />
<br />
Purchasing Estimate
<br />
<br />Local Search £{$purchase_lsearch}
<br />
Our Fees £{$purchase_ofee} inc VAT
<br />
Land Registry Fees £{$purchase_lrfee}
<br />
Environmental search £{$purchase_esearch}
<br />
Local registry search £{$purchase_lrsearch}
<br />
Bankruptcy search £{$purchase_bsearch}
<br />
Telegraphic Transfer Fee £{$purchase_ttfee} inc VAT
<br />
Stamp duty land transaction return £{$purchase_sdltr} inc VAT
<br />
Stamp duty £{$purchase_sduty}
<br />
Total = £{$purchase_total}";

$is_start = false;
$total = $total + $purchase_total;

} else {
$purchase_est = "";
}

if (isset($_POST['sales'])) {

//Read in and validate the post purchase
$price = (int)htmlentities($_POST['sales'], ENT_QUOTES);	

// Sales estimate variables
// Our fee
$sales_ofee = 0.00;
// Telegraphic transfer fee
$sales_ttfee = 35.25;
// Out copy entries
$sales_ocentries = 8.00;
// Sales total
$sales_total = 0.00;

/***** SALES ESTIMATES *****/

if (($price >= 0) && ($price <=65000))  {	
	$sales_ofee = 464.13;
}

if (($price >= 65001) && ($price <= 119999))  { 
	$sales_ofee = 499.38;
}

if (($price >= 120000) && ($price <=150000))  { 
	$sales_ofee = 558.13;
}

if (($price >= 150001) && ($price <=200000))  { 
	$sales_ofee = 581.63;
} 

if (($price >= 200001) && ($price <=250000))  { 
	$sales_ofee = 616.87;
}

if (($price >= 250001) && ($price <=300000))  { 
	$sales_ofee = 675.62;
}

$sales_total = $sales_ofee + $sales_ttfee + $sales_ocentries;

$sales_est = "<br />
<br />
Sales Estimate
<br />
<br />
Our Fees £{$sales_ofee} inc VAT
<br />
Telegraphic Transfer Fee £ {$sales_ttfee} inc VAT
<br />
Office Copy Entries £{$sales_ocentries} inc VAT
<br />
<br />
Total = {$sales_total}";

$is_start = false;
$total = $total + $sales_total;

} else {
$sales_est = "";
}

if ($is_start===true) {

$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Calculator</title>
</head>
<body>
<form method='post' action='calculate.php'>
Purchase price
<br />
£<input name='purchase' type='text' value='0' size='20' />
<br />
<br />
Sales price
<br />
£<input name='sales' type='text' value='0' size='20' />
<br />
<br />
<input name='calc' type='submit' value='Calculate' />
</form>
</body>
</html>";

} else {

$html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>Calculator</title>
</head>
<body>
{$purchase_est}
<br />
<br />
{$sales_est}
<br />
<br />
Total: {$total}
</body>
</html>";

}

echo $html;
?>

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.