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 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; ?> 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 Link to comment https://forums.phpfreaks.com/topic/264392-php-if-else/#findComment-1354895 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.