Forum Moderators: coopster
For example if height = 2200 and width = 1000 then 2 x sides 2200 x 570, 1 x top 964 x 570, 1 base 964 x 570.
... lots of coding to do with different sizes
I want to be able to go on the page type in the 2 inputs hit a button and the results show either in the page or an i frame.
<input type=”text”name=”height”><br>
<input type=”text”name=”width”><br>
<input type=”submit”> $adjusted_width=$width – 64;
$height=”$height”;
Echo” <p>Sides (2) $height x 570;,<br>
Top (1) $adjusted_width x 570<br>
Base (1) $adjusted_width x 570 </p>”;
[edited by: not2easy at 8:01 pm (utc) on Aug 17, 2017]
[edit reason] anonymized autogen content [/edit]
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
// define variables and set to empty values
$heightErr = $widthErr = "";
$height = $width=$deduct="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["height"])) {
$heightErr = "Height is required and must be numerical";
} else {
$height = test_input($_POST["height"]);
}
if (empty($_POST["width"])) {
$widthErr = "Width is required and must be numerical";
} else {
$width = test_input($_POST["width"]);
}
if (empty($_POST["deduct"])) {
$deduct = "";
} else {
$deduct = test_input($_POST["deduct"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h2>Estimator</h2>
<p><span class="error">* required field.</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Height: <input type="number" name="height"required><span class="error">* <?php echo $heightErr;?></span>
<br><br>
Width: <input type="number" name="width"required><span class="error">* <?php echo $widthErr;?></span>
<input type="hidden"name="deduct"value="36">
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo"<h1>Height: ";
echo $height;
echo"<br><br>Width: ";
$adj_width=$width-$deduct;
echo $adj_width;
echo"</h1>";
?>
</body>
</html>