title: Message after submit on radio button
body: <p>I'm working on a simple quiz. One question is displayed at a time with 3 possible answers on radio buttons. The answer for each question is stored in a table from a database called
   SOLUTION:</p>
  
  <p><a href="https://i.stack.imgur.com/b57IU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b57IU.jpg" alt="enter image description here"></a></p>
  
  <p>What I’m trying to do in the program is to show a message of 'Try again!' every time the user answers the question badly after clicking on SUBMIT. I have implemented it in the following code but I do not know why I always get the message of 'Try again!' when I click submit. Maybe it is because I put an 'else' after an 'empty'? Or because I'm not comparing it well with the correct variable? Can you help me find out the mistake?</p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;?php
  $Err = "";
  $Try = "";
  if ($_SERVER["REQUEST_METHOD"] == "POST") {
      if (empty($_POST["choice"])) {
          $Err = "Please select option";
      }
      else{
          if($_POST["choice"] != "solution_number FROM solution WHERE exercise_id_fk=$id"){
              $Try =  "Try again!";
          }
      }
  }
  ?&gt;
  
  &lt;form action='' method='post'&gt;
      &lt;input type="radio" name="choice" value= "1"  /&gt;&lt;img src="&lt;?php echo $row["image_path_A"] ?&gt;"/&gt;&lt;br&gt;
      &lt;input type="radio" name="choice" value= "2" /&gt;&lt;img src="&lt;?php echo $row["image_path_B"] ?&gt;"&gt;&lt;br&gt;
      &lt;input type="radio" name="choice" value= "3" /&gt;&lt;img src="&lt;?php echo $row["image_path_C"] ?&gt;"&gt;&lt;br&gt;
      &lt;br&gt;&lt;br&gt;
      &lt;span class="error"&gt;&lt;?php echo $Err;?&gt;&lt;/span&gt;
      &lt;span class="try"&gt;&lt;?php echo $Try;?&gt;&lt;/span&gt;
  
  
  &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;!--- Select difficulty ---&gt;
  
      &lt;p2&gt;Select difficulty level:&lt;/p2&gt;
  
      &lt;form action='' method='post'&gt;
          &lt;select name="choose" id="choose"&gt;&gt;
          &lt;option value="1" &lt;?php if($row["difficulty"]=="1") { echo "selected"; } ?&gt; &gt;1&lt;/option&gt;
          &lt;option value="2" &lt;?php if($row["difficulty"]=="2") { echo "selected"; } ?&gt; &gt;2&lt;/option&gt;
          &lt;option value="3" &lt;?php if($row["difficulty"]=="3") { echo "selected"; } ?&gt; &gt;3&lt;/option&gt;
          &lt;option value="4" &lt;?php if($row["difficulty"]=="4") { echo "selected"; } ?&gt; &gt;4&lt;/option&gt;
          &lt;option value="5" &lt;?php if($row["difficulty"]=="5") { echo "selected"; } ?&gt; &gt;5&lt;/option&gt;
      &lt;/select&gt;
  
          &lt;input class="buttonSubmit" type="submit" name="submit" value="Submit"&gt;
          &lt;?php
          if ($next_question_id &gt;= 0) {
          ?&gt;
              &lt;a href="?id=&lt;?php echo $next_question_id; ?&gt;&amp;order=&lt;?php echo $next_question_order; ?&gt;" class="buttonNext" &gt;Next Question&lt;/a&gt;
          &lt;?php
          }
          ?&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>And my PHP:</p>
  
  <pre><code>&lt;?php
  
  if (isset($_POST['submit'])) {
      $user_id = $_SESSION['user_id'];
      $user_check_query = "SELECT * FROM users WHERE id='$user_id'";
  
      if(isset($_POST['choice'], $_POST['choose'])){
              $choice_answer=$_POST['choice'];
              $difficulty=$_POST['choose'];
  
            $query = "INSERT INTO answers (exercise_id_fk, student_id, difficulty_change, difficulty_student, choice_answer, correct_answer) VALUES ('$id','$user_id', (SELECT IF(difficulty='$difficulty','NO','YES') FROM exercises WHERE exercise_id=$id), '$difficulty', '$choice_answer', (SELECT IF(solution_number='$choice_answer','1','0') FROM solution WHERE exercise_id_fk=$id))";
          $sql=mysqli_query($conn,$query);
      }
  }
  ?&gt;
  </code></pre>