I don't see the edit button; sorry for making a new post.
After much testing, I think I have it down. Here's the code for the HTML form:
<html>
<title>Basic Physics Calculator // F=ma</title>
<head></head>
<body>
<CENTER>
<form action="physicsfunction.php" method="post">
Please enter the number 0, or positive numbers, into two (and only two) of the following text boxes, and click submit to find the result.
<br>
<b>IMPORTANT</b>: If used in the calculation, mass must have a value greater than zero!
<br>
<br>
<br>
Force: <input type="text" name="force" size="10"> N
<br>
Mass: <input type="text" name="mass" size="10"> kg.
<br>
Acceleration: <input type="text" name="acceleration" size="10"> m/s²
<br>
<input type="submit" value="Submit">
</CENTER>
<br>
<i>Reference:
<br>
N = Newtons, a unit of measurement named after Sir Isaac Newton himself.
<br>
kg. = Kilograms.
<br>
m/s² = (meters per second)²</i>
</body>
</html>
Here's the new version of my PHP code:
<html>
<title>Basic Physics Calculator // F=ma</title>
<head></head>
<body>
<?php
// Use the form to determine variables.;
$Mass = $_POST ['mass'];
$Acceleration = $_POST ['acceleration'];
$Force = $_POST ['force'];
// Determine which variable received no input, solve the variable, and then print the appropriate statement.
if (($Force == "") && ($Mass > 0) && ($Acceleration > 0)) {
$Force = $Mass * $Acceleration;
$Statement = 'If an object with a mass of '.$Mass.' kg. is moving with an acceleration of '.$Acceleration.' m/s², the force initially exerted on the object was '.$Force.' N.';
echo $Statement;
}
if (($Mass == "") && ($Force > 0) && ($Acceleration > 0)) {
$Mass = $Force / $Acceleration;
$Statement = 'If an object had '.$Force.' N exerted onto it, causing it to move with an acceleration of '.$Acceleration.' m/s², the mass of the object must be '.$Mass.' kg.';
echo $Statement;
}
if (($Acceleration == "") && ($Force > 0) && ($Mass > 0)) {
$Acceleration = $Force / $Mass;
$Statement = 'If a '.$Mass.' kg. object is met with a force of '.$Force.' N, it will accelerate at a rate of '.$Acceleration.' m/s².';
echo $Statement;
}
// Error Control.
if (($Force == "") && ($Mass == "") && ($Acceleration == "")) {
echo 'ERROR: Please input numerical values for two out of the three variables. Click the BACK button to try again.';
}
if (($Force == "") && ($Mass == "") && ($Acceleration != "")) {
echo 'ERROR: Please input numerical values for two out of the three variables. Click the BACK button to try again.';
}
if (($Force == "") && ($Acceleration == "") && ($Mass != "")) {
echo 'ERROR: Please input numerical values for two out of the three variables. Click the BACK button to try again.';
}
if (($Mass == "") && ($Acceleration == "") && ($Force != "")) {
echo 'ERROR: Please input numerical values for two out of the three variables. Click the BACK button to try again.';
}
if (($Force < 0) && ($Force !="")) {
echo 'ERROR: Please only use the number 0 and/or positive numbers. Click the BACK button to try again.';
}
if (($Mass <= 0) && ($Mass != "")) {
echo 'ERROR: An object must have a mass to exist. Click the BACK button to try again.';
}
if (($Acceleration < 0) && (Acceleration != "")) {
echo 'ERROR: Please only use the number 0 and/or positive numbers. Click the BACK button to try again.';
}
if (($Force != "") && ($Mass != "") && ($Acceleration != "")) {
echo 'DANGER Will Robinson! Information overload! You filled in too many values. Click the BACK button to try again.';
}
?>
</body>
</html>
Again, any constructive criticism would be greatly appreciated! Feel free to use this code and/or test it out for me. For now, I will mark this thread as resolved.