kevinritt Posted March 30, 2009 Share Posted March 30, 2009 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 More sharing options...
corbin Posted March 30, 2009 Share Posted March 30, 2009 Looks like you're relying on register globals, which is a terrible idea. Look into a $_GET or $_POST tutorial. Link to comment https://forums.phpfreaks.com/topic/151688-form-input-not-showing/#findComment-796600 Share on other sites More sharing options...
kevinritt Posted March 30, 2009 Author Share Posted March 30, 2009 I tried adding if (isset($_POST['submit']) { ... all the other php stuff ...html form <? } ?> But that didn't work Link to comment https://forums.phpfreaks.com/topic/151688-form-input-not-showing/#findComment-796602 Share on other sites More sharing options...
kevinritt Posted March 30, 2009 Author Share Posted March 30, 2009 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> Link to comment https://forums.phpfreaks.com/topic/151688-form-input-not-showing/#findComment-796605 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.