Question: Your assignment is to develop PHP code to process the form submission and its values and perform and display the converted temperature. There is some

Your assignment is to develop PHP code to process the form submission and its values and perform and display the converted temperature.

There is some starter PHP code to help you.

One field is coded as sticky to help you code the other ones as sticky which is a requirement.

Make selects sticky.

// function to calculate converted temperature

function convertTemp($temp, $unit1, $unit2)

{

// conversion formulas

// Celsius to Fahrenheit = T(C) 9/5 + 32

// Celsius to Kelvin = T(C) + 273.15

// Fahrenheit to Celsius = (T(F) - 32) 5/9

// Fahrenheit to Kelvin = (T(F) + 459.67) 5/9

// Kelvin to Fahrenheit = T(K) 9/5 - 459.67

// Kelvin to Celsius = T(K) - 273.15

// You need to develop the logic to convert the temperature based on the selections and input made

} // end function

// Logic to check for POST and grab data from $_POST

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

// Store the original temp and units in variables

// You can then use these variables to help you make the form sticky

// then call the convertTemp() function

// Once you have the converted temperature you can place PHP within the converttemp field using PHP

// I coded the sticky code for the originaltemp field for you

$originalTemperature = $_POST['originaltemp'];

$originalUnit = $_POST['originalunit'];

$conversionUnit = $_POST['conversionunit'];

$convertedTemp = convertTemp($originalTemperature, $originalUnit, $conversionUnit);

} // end if

?>

Temperature Converter

CTEC 127 - PHP with SQL 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!