/    Sign up×
Community /Pin to ProfileBookmark

PHP area calculation

Hi there

Im trying to write some PHP code for my company in order to calculate the cost of a product.

We sell security gates and grilles, In order to provide a customer “quick quote”, I want the customer to select which type(s) of product they require from a drop down box (which will set the price per SQ mtr) and then input in the width X height dimensions and get a total at the bottom.

For instance:

[Option 1] = 16mm Fixed Security Bars = £80.70 SQ Mtr
[Option 2] = Diamond Mesh Grille = £51.11 SQ Mtr

What I need to calculate is this:

[Option 1] Width x Height x £80.70 +VAT x 2 = [Product Price]

[Option 2] Width x Height x £51.11 +VAT x 2 = [Product Price]

[Option….. So on]

[TOTAL]

Possibly email them and us the quote details.

Does anyone know of a script which does this or similar, or anyone interested in writing some code ?

I appreciate this is not something simple, for me anyway.

Kind Regards

Chris

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@criterion9Feb 19.2010 — What code do you have already?
Copy linkTweet thisAlerts:
@esquiladoFeb 19.2010 — I'm happy to help, just would like to see that you've started something.
Copy linkTweet thisAlerts:
@HampsterFeb 22.2010 — This sound simple enough to do in javascript. The "quick quote" to be done within the web page, and not e-mailed.

Just a suggestion.
Copy linkTweet thisAlerts:
@ericatekkaFeb 22.2010 — Enjoy my dirty code i wrote from you. I would not put this on the web but its a start:
[code=php]<?php

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

$email = $_POST['email'];
$type = $_POST['type'];
$hie = $_POST['hie'];
$wid = $_POST['wid'];

if($type == '16mm_Fixed_Security_Bars'){
$cost = 80.70;
}elseif($type == 'Diamond_Mesh_Grille'){
$cost = 51.11;
}

$tot = $hie * $wid * $cost;

$mailer = 'Total Cost for $type is $ $tot';

mail($email,'Quote for Metals',$mailer);


}

?>

<html>
<head>
<title>Calculator</title>
</head>
<body>


<h1>Quote Maker</h1>
<br><br>
<form method="POST" action="<? echo $_SERVER['SELF'] ?>">
<table>
<tr><th>Type</th><th>Width</th><th>Height</th></tr>
<tr>
<td><select name='type'>
<option value='16mm_Fixed_Security_Bars'>16mm Fixed Security Bars</option>
<option value='Diamond_Mesh_Grille'>Diamond Mesh Grille</option>
</select></td>

<td><input type="text" TABINDEX="1" name="wid" size="20"></td>
<td><input type="text" TABINDEX="2" name="hie" size="20"></td>
</tr>
<tr><td>Enter your email address here</td><td colspan='2'><input type="text" TABINDEX="3" name="email" size="20"></td></tr>
<tr><td colspan='3'><input type="submit" value="Submit" name="quoter"></td></tr>
</body>
</html>


[/code]
×

Success!

Help @ccn1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...