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
https://forums.phpfreaks.com/topic/111587-solved-using-ifelse-in-a-request-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.