this image should explain it.
input is how the page should look and the equation is well... how the input should be used. HTML/JS is prefered, PHP is you must. 15c if you tried. 100c for the one i like.
well since I don't know where you are getting the input from, I'll just create those variables.
PHP Code:<?php
//Define Variables
$fileSize = "";
$uploaded = "";
$downloaded = "";
$finalRatio = "0";
//Math
$totalDown = $fileSize + $downloaded;
$finalRatio = $uploaded / $totalDown;
//Displays the values (optional)
echo $totalDown;
echo "<br />";
echo $finalRatio;
?>
Last edited by 0010111; 12-09-2008 at 06:21 PM.
PHP Code:<?php
if(isset($_POST) {
//Define Variables
$fileSize = "$_POST['fileSize']";
$uploaded = "$_POST['uploaded']";
$downloaded = "$_POST['downloaded']";
$finalRatio = "1";
//Math
$totalDown = $fileSize + $downloaded;
$finalRatio = $uploaded / $totalDown;
//Displays the values (optional)
echo $totalDown;
echo "<br />";
echo $finalRatio;
}
?>here is what I came up with, save it as a .php and make sure the form redirects to itself; also this does not prevent users from placing in an alphabetical character, therefor the equation will screw up; but rite now I'm too lazy to implement oneHTML Code:<form action="index.php" method="post"> File Size: <input type="text" name="fileSize" /> Uploaded: <input type="text" name="uploaded" /> Downloaded: <input type="text" name="downloaded" /> <input type="submit" value="Submit" /> <input type="hidden" name="action" value="login" /> </form>
Last edited by diabolo; 12-09-2008 at 06:37 PM.
the script doesn't define what it measures it in; you can interpret it any way you want; ie
if you want it as bytes
the would put 100 bytes for 1 MB, I think
just one tip:
dont use variables into double quotes:
like this its better:PHP Code:$fileSize = "$_POST['fileSize']";
$uploaded = "$_POST['uploaded']";
$downloaded = "$_POST['downloaded']";
$finalRatio = "1";
PHP Code:$fileSize = $_POST['fileSize'];
$uploaded = $_POST['uploaded'];
$downloaded = $_POST['downloaded'];
$finalRatio = 1; // <-- now its evaluate as integer
PHP & MySQL Web Developer
Free Domain co.cc
thank you tttony
Edit:
<?php
//Define Math Function
function doMath($fileSize, $uploaded, $downloaded) {
$totalDown = $fileSize + $downloaded;
$finalRatio = $uploaded / $totalDown;
}
if(isset($_POST) {
//Define Variables
$fileSize = $_POST['fileSize'];
$uploaded = $_POST['uploaded'];
$downloaded = $_POST['downloaded'];
$finalRatio = 1;
//Checks
if(is_numeric($fileSize) == FALSE){
$error = "Please enter a numeric value for File Size.";
}
if(is_numeric($uploaded) == FALSE){
$error = "Please enter a numeric value for Uploaded.";
}
if(is_numeric($downloaded) == FALSE){
$error = "Please enter a numeric value for Downloaded.";
}
if((isset($_POST) AND (is_numeric($downloaded)){
doMath($fileSize, $uploaded, $downloaded);
}
//Displays the values (optional)
echo $totalDown;
echo "<br />";
echo $finalRatio;
}
?>
<form action="index.php" method="post"> <!-- this is index.php -->
File Size: <input type="text" name="fileSize" />
Uploaded: <input type="text" name="uploaded" />
Downloaded: <input type="text" name="downloaded" />
<input type="submit" value="Submit" />
<input type="hidden" name="action" value="login" />
</form>
not fully done, few bugs but busy
Last edited by diabolo; 12-12-2008 at 03:00 PM. Reason: Automerged Doublepost