dsandif Posted April 8, 2009 Share Posted April 8, 2009 I trying to reverse engineer a php output. I've got the code, but I can't quite get the html to work with it. her is the code: <?php $age = 20; if ($age >= 18 && $age < 50) { print "You're in the prime of your life\n"; } else { print "You're not in the prime of your life\n"; } ?> and here is the html: <html> <head></head> <body> <form action="age.php" method="post"> Enter your age: <input type="number" name="age" size="30"> <input type="submit" value="Send"> </form> </body> </html> I am a beginner at this & trying to get better.Thanks for your input. dsandif Link to comment https://forums.phpfreaks.com/topic/153098-solved-html-seems-off/ Share on other sites More sharing options...
ram4nd Posted April 8, 2009 Share Posted April 8, 2009 PHP: <?php if(isset($_POST['submit'])) { $age = $_POST['age']; if ($age >= 18 && $age < 50) print "You're in the prime of your life\n"; else print "You're not in the prime of your life\n"; } ?> HTML: <html><body> <form action="age.php" method="post"> Enter your age: <input type="text" name="age" size="30"> <input name="submit" type="submit" value="Send"> </form></body></html> Link to comment https://forums.phpfreaks.com/topic/153098-solved-html-seems-off/#findComment-804221 Share on other sites More sharing options...
dsandif Posted April 8, 2009 Author Share Posted April 8, 2009 this is the out put I get when I put in an age: = 18 && $age < 50) print "You're in the prime of your life\n"; else print "You're not in the prime of your life\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/153098-solved-html-seems-off/#findComment-804237 Share on other sites More sharing options...
kenrbnsn Posted April 8, 2009 Share Posted April 8, 2009 This means one of the following: 1) PHP isn't installed on the server 2) age.php is really named age.html 3) you're invoking the file that contains the form incorrectly. It must be invoked via the server not buy double clicking. Ken Link to comment https://forums.phpfreaks.com/topic/153098-solved-html-seems-off/#findComment-804256 Share on other sites More sharing options...
dsandif Posted April 8, 2009 Author Share Posted April 8, 2009 WAMP is installed correctly, so php is there, age.html and age.php are correctly named so the only thing I not clear is the invoking, although I have gotten another small php script to run, so I don't think its that either. Over all, everything looks goood, still not sure it won't run. dsandif- Link to comment https://forums.phpfreaks.com/topic/153098-solved-html-seems-off/#findComment-804260 Share on other sites More sharing options...
kenrbnsn Posted April 8, 2009 Share Posted April 8, 2009 You have to start age.html by putting http://localhost/age.html in to the address line of the browser. You can not start it by double clicking on it. Ken Link to comment https://forums.phpfreaks.com/topic/153098-solved-html-seems-off/#findComment-804439 Share on other sites More sharing options...
dsandif Posted April 9, 2009 Author Share Posted April 9, 2009 Many thanks. You were right. Thank you for your wisdom and and patience. dsandif- Link to comment https://forums.phpfreaks.com/topic/153098-solved-html-seems-off/#findComment-805224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.