Jump to content

form input not showing


kevinritt

Recommended Posts

I'm sure there's any 'easy' explanation for why my page doesn't show the values entered into the text field, but I cannot figure it out. Appreciate any help. Here's the code:

<?
if ($convert_method == "ftoc")
{
$new_temp = ($input_temp -32)*(5/9);
echo "Your temperature: " .$input_temp;
echo "was converted from Fahrenheit to" .$new_temp. "Celsius<br>";
}
else if ($convert_method == "ctof")
{
$new_temp = ($input_temp*(9/5))+32;
echo "Your temperature:" .$input_temp;
echo "was converted from Celsius to" .$new_temp. "Fahrenheit<br>";

} 
?>
<html>
<head>
<title>Temperature Conversion</title>
</head>
<body>

<form action="" name="conversion_form" method="post">
Enter a temperature: <input name="input_temp" type="text"><br />
Choose your temperature scale:<br /> 

  <input type="radio" name="convert_method" value="ftoc"> Fahrenheit to Celsius
  <br /> 
  <input type="radio" name="convert_method" value="ctof">Celsius to Fahrenheit
<br />
<input name="submit" type="submit" value="convert">

</form>

</body></html>

and here's the actual page: http://northshorewebdesign.net/alex/lab10Q3.php

The form is just to show the conversion of F to C and C to F when submitted. When I enter something, nothing happens.  ???

Link to comment
https://forums.phpfreaks.com/topic/151688-form-input-not-showing/
Share on other sites

I tried this as well:

<?
if (isset($_POST['submit'])) 
if ($convert_method == "ftoc")
{
$new_temp = ($input_temp -32)*(5/9);
echo "Your temperature: " .$input_temp;
echo "was converted from Fahrenheit to" .$new_temp. "Celsius<br>";
}
else if ($convert_method == "ctof")
{
$new_temp = ($input_temp*(9/5))+32;
echo "Your temperature:" .$input_temp;
echo "was converted from Celsius to" .$new_temp. "Fahrenheit<br>";

} 
?>
<html>
<head>
<title>Temperature Conversion</title>
</head>
<body>

<form action="" name="conversion_form" method="post">
Enter a temperature: <input name="input_temp" type="text"><br />
Choose your temperature scale:<br /> 

  <input type="radio" name="convert_method" value="ftoc"> Fahrenheit to Celsius
  <br /> 
  <input type="radio" name="convert_method" value="ctof">Celsius to Fahrenheit
<br />
<input name="submit" type="submit" value="convert">

</form>

</body></html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.