cjlong Posted November 9, 2010 Share Posted November 9, 2010 Hello, I'm trying to create a form with a numerical input. Based on the numerical Input I was trying to get a response. Basically a value is input within a form and I'm trying to create an if else statement to give me two outputs based on the number entered. I'm new to php and I'm trying to learn. Please help me. This is the code: Form Value Code: <body> <div align="center"> <form action="labcrosscheck.php" method="post"> <span class="style5">GGT Value:</span> <input type="text" name="ggtvalue" /> <input type="submit" /> </form> </div> </body> Output File Code: <body> <?php if ($ggtvalue=="<55") echo $_POST["Cardiovascular Disease is less likely"]; else echo $_POST["Cardiovascular Disease is suspect"]; ?> </body> Link to comment https://forums.phpfreaks.com/topic/218224-if-else-help/ Share on other sites More sharing options...
requinix Posted November 9, 2010 Share Posted November 9, 2010 And the problem is... what? That you don't get any kind of message for anything you enter? 1. You're trying to use register_globals in your code, except it's disabled. Don't enable it. Just use $_POST["ggtvalue"] instead. 2. The two $_POST["Cardiovascular..."] things don't exist. $_POST is only for stuff that came in through a form with method=post and those two messages did not. Making fixes for those two, as well as checking that the form was actually submitted (instead of assuming it was), you might end up with if (isset($_POST["ggtvalue"])) { // check that the form was submitted if ($_POST["ggtvalue"]==" echo "Cardiovascular Disease is less likely"; else echo "Cardiovascular Disease is suspect"; } ?> Link to comment https://forums.phpfreaks.com/topic/218224-if-else-help/#findComment-1132346 Share on other sites More sharing options...
cjlong Posted November 9, 2010 Author Share Posted November 9, 2010 Thank You for your help. Got it to work Link to comment https://forums.phpfreaks.com/topic/218224-if-else-help/#findComment-1132355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.