Jump to content

[SOLVED] Using if....else in a request form.


Wolverine68

Recommended Posts

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.