Wolverine68 Posted June 24, 2008 Share Posted June 24, 2008 I'm trying to setup a feedback form that prints out a response based on the rating that the user enters. No matter what number I put in, the response that prints out is the response that's suppose to print when a 1 is entered. The html and php code are shown below. <html> <body> <?php if ($_POST['num'] = 1) { echo "We're sorry to hear you're not pleased. How can we improve?"; } else if ($_POST['num'] = 2) { echo "That's not a very good rating. We will do our best to improve."; } else if ($_POST['num'] = 3) { echo "That's not bad, but I'm sure we could do better."; } else if ($_POST['num'] = 4) { echo "Thank you for the good rating."; } else if ($_POST['num'] = 5) { echo "We're glad to hear you are so pleased with our service and look forward to serving you in the future!"; } else { echo "You entered an invalid value, try again."; } ?> </body> </html> <html> <body><form action="practicephp.php" method="post"> Enter a number to rate our service: <input type="text" name="num"> <input type="submit" value="submit"> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
tpimental Posted June 24, 2008 Share Posted June 24, 2008 They should be "elseif" not "else if" Quote Link to comment Share on other sites More sharing options...
Wolverine68 Posted June 24, 2008 Author Share Posted June 24, 2008 You're right. Thanks for pointing that out. Still have the same problem though. Quote Link to comment Share on other sites More sharing options...
tpimental Posted June 24, 2008 Share Posted June 24, 2008 The "=" signs should be "==" (2 equal signs) Quote Link to comment Share on other sites More sharing options...
Wolverine68 Posted June 24, 2008 Author Share Posted June 24, 2008 Thanks. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted June 24, 2008 Share Posted June 24, 2008 They should be "elseif" not "else if" Either way works... In PHP, you can also write 'else if' (in two words) and the behavior would be identical to the one of 'elseif' (in a single word) -- http://www.php.net/control-structures.elseif Quote Link to comment 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.