anujchhabria Posted June 18, 2012 Share Posted June 18, 2012 Hello, This is my HTML file.. <html> <body> <form action="check.php" method="post"> Name: <input type="text" name="fname" /> <input type="submit" /> </form> </body> </html> and this is my check.php file: <?php $question=substr($fname,0); if ($question=="Bob Jones") { $answer=="admin"; } echo $_POST["fname"]; echo ',' + $answer; ?> For some reason it is not displaying anwser correctly Quote Link to comment https://forums.phpfreaks.com/topic/264392-php-if-else/ Share on other sites More sharing options...
litebearer Posted June 18, 2012 Share Posted June 18, 2012 try... <?php $question = $_POST['fname']; if ($question=="Bob Jones") { $answer = "admin"; }else{ $answer = "nobody"; } echo $question . ", " . $answer; ?> Quote Link to comment https://forums.phpfreaks.com/topic/264392-php-if-else/#findComment-1354893 Share on other sites More sharing options...
anujchhabria Posted June 18, 2012 Author Share Posted June 18, 2012 thx. worked like a charm Quote Link to comment https://forums.phpfreaks.com/topic/264392-php-if-else/#findComment-1354895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.