title: How to display error message inside a pop up window instead of moving to a new page?
body: <p>I'm new to php, and I'm new here and I don't know if it's right for me to ask a question in such a long manner. I'm sorry if that's not how it is done here.</p>
  
  <ul>
  <li>I have the following code which is used to enter a question and it's four choices.</li>
  <li>4 choices are entered in text boxes with a radio button corresponding to each.</li>
  <li>The button clicked out of those 4 will be the value of $correct</li>
  <li>$difflevel, $agegroup and $catId are again, the values from a set of radio buttons.</li>
  </ul>
  
  <p>The following is my code</p>
  
  <pre><code>    if(isset($_POST['submit']))
      {
  
      extract($_POST);
      $question=mysqli_real_escape_string($con,$question);
      $option[0]=mysqli_real_escape_string($con,$option[0]);
      $option[1]=mysqli_real_escape_string($con,$option[1]);
      $option[2]=mysqli_real_escape_string($con,$option[2]);
      $option[3]=mysqli_real_escape_string($con,$option[3]);
  
      mysqli_query($con,"insert into questions(question, op1,op2,op3,op4,correct,difflevel,ageGroup,catId) values
      ('$question','$option[0]','$option[1]','$option[2]','$option[3]',$correct,$difflevel,$ageGroup,$catId)") or die("Some error");
  
      $questionId = mysqli_insert_id($con);
  
      if($_POST['catId']=="")//QUESTIONS MUST CONTAIN AT LEAST ONE CATEGORY
          die("Please select category of the question entered.");
  
      if($_POST['difflevel']=="")//DIFFICULTY LEVEL SHOULD BE SET
          die("Please select difficulty of the question entered.");
  
      if($_POST['ageGroup']=="")//AGEGROUP SHOULD BE SET
          die("Please select age group of the question entered.");
  
      if($_POST['correct']=="")//CORRECT ANSWER SHOULD BE SET
          die("Please select correct answer for the question entered.");
      }
  </code></pre>
  
  <p>Since all fields are mandatory, I need an error report if not all are filled(or clicked). Right now, when the error occur, it's taken to a new page, and hence all that I typed are lost and I have to type them again.
  So instead of going to the next page, is it possible to show a pop-up window with the error so that I can correct the mistake and continue from where I stopped?
  Any help is so much appreciated. Thanks in advance.</p>