I'm working on my first project and self-teaching myself through the entire things, so please excuse this uber basic question.
How do I make the submit work within the page?
Currently, I have: the function:
$tempC = 32;
$tempF = $tempC * 1.8 + 32;
echo $tempF;
And then I am creating the form:
<form>
<input type="text" name="Celsius">
<input type="submit" value="Calculate"
</form>
How do I link the php variables to the form?
ETA: My hope is to be able to enter Celsius into the field and have the Fahrenheit populate below it. I've been following some tutorials but in an effort to avoid copying and pasting w/o understanding, I've just decided to handwrite it from scratch myself...Trial and error, you know. In any case, here's where I'm at now...the button isn't updating the values. :-/
function runConversion () {
$tempC = 32;
$tempF = 0;
$tempF = $tempC * 1.8 + 32;
echo $tempF . "F ";
echo $tempC . " C";
}
?>
<?php runConversion(); ?>
<form action="DT-Converter.php" method="post">
<input type="text" name="Celsius">
<input type="submit" name="convert" value="Calculate">
</form>
<?php
if(isset($_POST['convert'])) {
$tempC = $_POST['Celsius'];
runConversion();
}