View Single Post
Old 14-07-2004, 16:07   #1
Bifta
Inactive
 
Join Date: Jul 2003
Location: Eglinton, Co. Derry
Posts: 7,640
Bifta has a nice shiny starBifta has a nice shiny star
Bifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny starBifta has a nice shiny star
Filtering out comma's with PHP

I have a form with two price fields, if the customer enters a number over 500000, the form's target page forwards you on to another page telling you to contact the office for any enquiries over £500,00 0. The trouble is, if they enter an amount over 500000 with comma's, e.g. 750,000, the forms target page thinks it's 750 not 750000 and carries on trying to do it's bit. Is there an easy way to filter out the comma's on the target page before it does it's price detection bit?

Source for the form page:

Code:
<form action="test.php" method="Post">
  <table  border="0" cellspacing="0" cellpadding="3">
    <tr bgcolor="F1C440">
      <td colspan="2" class="style10"><strong>Purchasing</strong></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td class="style10">Name</td>
      <td><input name="name" type="text" /></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td><span class="style10">Purchase Price<br>
        (No comma's)
      </span></td>
      <td><input name="price" type="text" value="0" /></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td colspan="2"><span class="style10">
        <input name="type" type="radio" value="freehold" checked />
Freehold
<input type="radio" name="type" value="leasehold" />
Leasehold</span></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td class="style10">Selling Price<br>
      (No comma's)  </td>
      <td><input name="sprice" type="text" id="sprice" value="0" /></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td colspan="2"><span class="style10">
        <input name="stype" type="radio" value="freehold" checked />
Freehold
<input type="radio" name="stype" value="leasehold" />
Leasehold
        </span></td>
    </tr>
    <tr bgcolor="#eeeeee">
      <td><span class="style5">            <input name="submit" type="submit" />
      </span></td>
      <td><span class="style6"></span></td>
    </tr>
  </table>
</form>
Source for the target page:

Code:
<?php
$toprice = $sprice + $price;
if ($toprice < 1)
{
header('Location: noprice.php');
}
else if ($price > 500000)
{
header('Location: contact.php');
}
else if ($sprice > 500000)
{
header('Location: contact.php');
}


?>

<?php 



$officecopy = 8;
$landregistrysearch = 4;
$localsearch = 170;
$banktransfer = 35.25;
$watersearch = 39.95;
$environmentsearch = 40;
$bankruptcysearch = 2;
$indemnity = 94;


if (((Double)$price)>500000)
  $d = 420;
else if (((Double)$price)>200000)
  $d = 220;
else if(((Double)$price)>100000)
  $d = 150;
else if(((Double)$price)>80000)
 $d = 100;
else if(((Double)$price)>50000)
 $d = 60;
else if(((Double)$price)>0)
 $d = 40;

if ($type=="freehold" )
{
$f = 495;


}


else
{
$f = 550;

}


if ($stype=="freehold" )
{
$sf = 450;

}
else
{
$sf = 550;

}



?>
<style type="text/css">
<!--
.style18 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #000000; }
.style20 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; }
.style22 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; }
.style23 {font-size: 10px}
a:link {
	color: #000000;
}
a:visited {
	color: #000000;
}
a:hover {
	color: #000000;
}
a:active {
	color: #000000;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<title>Online Conveyancing Quotation</title>
<p align="center"><span class="style20"><a href=# onclick="window.print();">Print</a> this quote &nbsp;&nbsp;Click <a href="#" onClick="history.go(-1);">here</a> to go back </span></p>
<table border="0" align="center" cellpadding="6" cellspacing="0">
  <tr>
    <td colspan="2" bgcolor="#F1C440"><div align="center" class="style20">Estimate Prepared For </div></td>
  </tr>
  <tr bgcolor="#eeeeee">
    <td class="style20"><strong>Name:</strong></td>
    <td class="style22"><span class="style18"><?php echo $name; ?></span></td>
  </tr>
  <tr bgcolor="#dddddd">
    <td class="style20"><strong>Date:</strong></td>
    <td class="style22"><span class="style18"><?php echo date("d /");  echo date("m /"); echo date("Y ");?></span></td>
  </tr>
</table>
<br />
<table width="80%"  border="0" align="center" cellpadding="3" cellspacing="0">
  <tr bgcolor="#F1C440">
    <td width="423" bgcolor="#F1C440"><span class="style18">Purchase Price 
    </span></td>
    <td><span class="style22">
      <?php 
	if ($price > 0)
	{ 
	echo "&pound;"; echo $price;
	}
	else 
	{
		echo "Not Applicable";
	}
	?>
    </span></td>
  </tr>
  <tr bgcolor="#F1C440">
    <td class="style20">Selling Price </td>
    <td><span class="style22">
      <?php 
	if ($sprice > 0)
	{ 
	echo "&pound;"; echo $sprice;
	}
	else 
	{
		echo "Not Applicable";
	}
	?>
    </span></td>
  </tr>
  <tr bgcolor="#000000">
    <td colspan="2" height=1></td>
  </tr>
  <tr bgcolor="#eeeeee">
    <td><span class="style20">Legal costs on </span></td>
    <td></td>
  </tr>
  <tr>
    <td><span class="style20">
      Purchasing <?php
	if ($type=="freehold" and $price > 0)
{

echo "- Freehold fee";
}
else if ($type=="leasehold" and $price > 0)
{

echo "- Leasehold fee";
}
else 
{
echo "";
}
	?>
</span></td>
    <td><span class="style22"><?php


	if ($type=="freehold" AND $price > 0)
{

echo "£"; printf ("%01.2f", $f);
}

else if ($type=="leasehold" AND $price > 0)
{
echo "£"; printf ("%01.2f", $f);
}


else
{
$f = 0;
echo "Not Applicable";
}
	?>
    </span></td>
  </tr>
  <tr>
    <td class="style20">Selling 
      <?php
	if ($stype=="freehold" and $sprice > 0)
{

echo "- Freehold fee";
}
else if ($stype=="leasehold" and $sprice > 0)
{

echo "- Leasehold fee";
}
else 
{
echo "";
}
	?></td>
    <td><span class="style22"><?php


	if ($stype=="freehold" AND $sprice > 0)
{

echo "£"; printf ("%01.2f", $sf);
}

else if ($stype=="leasehold" AND $sprice > 0)
{
echo "£"; printf ("%01.2f", $sf);
}


else
{
$sf = 0;
echo "Not Applicable";
}
	?>
    </span></td>
  </tr>
  <tr bgcolor="#F1C440">
    <td class="style20">Subtotal A </td>
    <td class="style22">&pound;<?php
	


$subtotala = ($f + $sf);
printf ($subtotala);

?>.00</td>
  </tr>
  <tr bgcolor="#eeeeee">
    <td colspan="2" class="style20">Payments for bank and insurance charges</td>
  </tr>
  <tr>
    <td class="style20">Bank Charges for Telegraphic Transfer Fee (each)</td>
    <td><span class="style22"><?PHP echo "£"; printf ("%01.2f", $banktransfer);
	
	?>
	</span></td>
  </tr>
  <tr>
    <td class="style20">Contribution to Professional Indemnity Insurance</td>
    <td class="style22"><?PHP echo "£"; printf ("%01.2f", $indemnity);
	
	?></td>
  </tr>
  <tr bgcolor="#F1C440">
    <td class="style20">Subtotal B </td>
    <td><span class="style22">&pound;<?php
	


$subtotalb = ($banktransfer + $indemnity);
printf ($subtotalb);

?>
    </span></td>
  </tr>
  <tr bgcolor="#eeeeee">
    <td colspan="2" class="style20">Disbursements payable to the government, local authority or other agencies in respect of Land Registry Fees, VAT, Stamp Duty Land Tax, search fees and other charges . These may be subject to alteration if the rates of Stamp Duty Land Tax or if the fees are changed or varied after the date of this estimate.</td>
  </tr>
  <tr>
    <td class="style20">V.A.T on our charges</td>
    <td><span class="style22">&pound;<?php
	

$feetotal = $f + $sf;
$vat = ($feetotal/100)*17.5;
printf ("%01.2f", $vat);

?>
    </span></td>
  </tr>
  <tr>
    <td><span class="style20"><a href="#" onClick="MM_openBrWindow('stampduty.php','','width=350,height=192')">Stamp Duty Land Tax </a></span></td>
    <td><span class="style22">
      <?php
	if (((Double)$price)>500000)
	$sd = ((Double)$price/100)*4;
	else if (((Double)$price)>250000)
	$sd = ((Double)$price/100)*3;
	else if (((Double)$price)>60000)
	$sd = ((Double)$price/100)*1;
	else if (((Double)$price)<60000)
	$sd = 0;
	?>
<?php 
if ($price > 0)
{
echo "£"; printf ("%01.2f", $sd);
}
else 
{
echo "Not Applicable";
}

 ?></span><span class="style23"></span></td>
  </tr>
  <tr>
    <td class="style20"><a href="#" onClick="MM_openBrWindow('landregistryfee.php','','width=350,height=137')">Land Registry Fees </a></td>
    <td><span class="style22"><?php 
	if ($price > 0)
	{ 
	echo "&pound;"; printf ("%01.2f", $d);
	}
	else 
	{
	$d = 0;
	echo "Not Applicable";
	}
	?></span></td>
  </tr>
  <tr>
    <td><span class="style20"><a href="#" onClick="MM_openBrWindow('bankruptcysearch.php','','width=350,height=100')">Bankruptcy Search</a> (each name) </span></td>
    <td><span class="style22">
      <?php 
	if ($price > 0)
	{ 
	echo "&pound;"; printf ("%01.2f", $bankruptcysearch);
	}
	else 
	{
	$bankruptcysearch = 0;
	echo "Not Applicable";
	}
	?>
    </span></td>
  </tr>
  <tr>
    <td class="style20"><a href="#" onClick="MM_openBrWindow('localauthoritysearch.php','','width=350,height=225')">Local Authority Search</a> (Approximate fee)</td>
    <td><span class="style22">
      <?php 
	if ($price > 0)
	{ 
	echo "&pound;"; printf ("%01.2f", $localsearch);
	}
	else 
	{
	$localsearch = 0;
	echo "Not Applicable";
	}
	?>
    </span></td>
  </tr>
  <tr>
    <td><span class="style20"><a href="#" onClick="MM_openBrWindow('officecopies.php','','width=350,height=138')">Office Copies</a> </span></td>
    <td><span class="style22">
      <?php 
	if ($sprice > 0)
	{ 
	echo "&pound;"; printf ("%01.2f", $officecopy);
	}
	else 
	{
	$officecopy = 0;
	echo "Not Applicable";
	}
	?>
    </span></td>
  </tr>
  <tr>
    <td><span class="style20"><a href="#" onClick="MM_openBrWindow('landregistrysearch.php','','width=350,height=152')">Land Registry Search</a> </span></td>
    <td><span class="style22">
      <?php 
	if ($price > 0)
	{ 
	echo "&pound;"; printf ("%01.2f", $landregistrysearch);
	}
	else 
	{
	$landregistrysearch = 0;
	echo "Not Applicable";
	}
	?>
    </span></td>
  </tr>
  <tr>
    <td class="style20"><a href="#" onClick="MM_openBrWindow('watersearch.php','','width=350,height=153')">Water Search</a> (optional)</td>
    <td><span class="style22">
      <?php 
	if ($price > 0)
	{ 
	echo "&pound;"; echo $watersearch;
	}
	else 
	{
	$watersearch = 0;
	echo "Not Applicable";
	}
	?>
    </span></td>
  </tr>
  <tr>
    <td class="style20"><a href="#" onClick="MM_openBrWindow('environmentalsearch.php','','width=350,height=126')">Environmental Search</a> (optional) </td>
    <td><span class="style22">
      <?php 
	if ($price > 0)
	{ 
	echo "&pound;"; printf ("%01.2f", $environmentsearch);
	}
	else 
	{
	$environmentsearch = 0;
	echo "Not Applicable";
	}
	?>
    </span></td>
  </tr>
  <tr bgcolor="#F1C440">
    <td><span class="style20">Sub Total C </span></td>
    <td><span class="style22">&pound;<?php
	
		$subtotalc = $watersearch + $environmentsearch + $vat + $sd + $d + $bankruptcysearch + $localsearch  + $officecopy + $landregistrysearch;
	
	printf ("%01.2f", $subtotalc); ?>
    </span></td>
  </tr>
  <tr bgcolor="F1C440">
    <td colspan="2" bgcolor="#FFFFFF"><div align="center" class="style20"><br>

    </div></td>
  </tr>
  <tr bgcolor="#F1C440">
    <td colspan="2"><div align="center" class="style20">SUMMARY</div></td>
  </tr>
  <tr bgcolor="F1C440">
    <td bgcolor="#FFFFFF" class="style20">Our Fees (subtotal A)</td>
    <td bgcolor="#FFFFFF"><span class="style22">
      &pound;<?php
	


$subtotala = ($f + $sf);
printf ($subtotala);

?>.00</span></td>
  </tr>
  <tr bgcolor="F1C440">
    <td bgcolor="#FFFFFF" class="style20">Other Payments (subtotal B) </td>
    <td bgcolor="#FFFFFF"><span class="style22">&pound;<?php
	


$subtotalb = ($banktransfer + $indemnity);
printf ($subtotalb);

?>
    </span></td>
  </tr>
  <tr bgcolor="F1C440">
    <td bgcolor="#FFFFFF" class="style20">Other Payments (subtotal C) </td>
    <td bgcolor="#FFFFFF"><span class="style22">&pound;<?php
	
		$subtotalc = $vat + $sd + $d + $bankruptcysearch + $localsearch  + $officecopy + $landregistrysearch + $watersearch + $environmentsearch;
	
	printf ("%01.2f", $subtotalc); ?>
    </span></td>
  </tr>
  <tr bgcolor="#eeeeee">
    <td class="style20">Total fees and disbursements </td>
    <td><span class="style22">&pound;<?php
	
		$finaltotal = $subtotala + $subtotalb + $subtotalc;
	
	printf ("%01.2f", $finaltotal); ?>
    </span></td>
  </tr>
  <tr bgcolor="F1C440">
    <td colspan="2" bgcolor="#FFFFFF" class="style22"><strong><br>
      Notes</strong><br>
      <br>
      In a Leasehold sale a further &pound;50.00 plus VAT may be charged for dealing with your Landlords in obtaining replies to a Leasehold Questionnaire. In some Leasehold cases there may be additional Solicitor's Costs, Land Registry fees and Stamp Duty Land Tax where a new lease/or extended lease  is being granted by the Landlord. <br>
      <br>
    Extra fees may be payable to comply with the lease conditions such as registration fees for notices and/or obtaining a Licence to Assign or a Deed of Covenant. <br>
    <br>
    Any further Bank Telegraphic Transfers required will be charged for at &pound;30.00 plus VAT. This may be where the mortgagee  requires the mortgage to be redeemed by Telegraphic Transfer, or if you request the sale proceeds to be sent direct to your bank. <br>
    <br>
    This Estimate has been prepared on the basis of information supplied by you. 
    We reserve the right to revise the estimate where additional work is required, such as, redemption of more than one mortgage, providing undertakings to others, drafting of Trust or other Deeds. The estimate also assumes that title is not defective and does not require work to remedy any defects. <br>
    <br>
    <p>We may at our discretion make an additional charge of &pound;80.00 plus VAT if completion has to take place less than 10 working days after exchange of contracts. </p>
    <p>We are obliged to take out compulsory indemnity insurance which means we are covered for any possible claims that may arise and you are protected by comprehensive professional indemnity insurance. We have included this charge as a contribution towards the cost of that cover. </p></td>
  </tr>
  <tr bgcolor="F1C440">
    <td colspan="2" bgcolor="#FFFFFF"><div align="center"><span class="style20"><a href=# onclick="window.print();"><br>
    Print</a> this quote &nbsp;&nbsp;Click <a href="#" onClick="history.go(-1);">here</a> to go back </span></div></td>
  </tr>
</table>
<br>
</body>
</html>
TIA
Bifta is offline   Reply With Quote