title: How can I process two different submit buttons in a single HTML form?
body: <p>If I have a form as in the below script:</p>
  
  <pre><code>&lt;html&gt; 
   &lt;?php
     session_start();
  
       $con=mysqli_connect("localhost","root","","QSTNS");
        if (mysqli_connect_errno()) {
            echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }
  
         $dsply=$_SESSION['q_indx'][$_SESSION['cindx']] ; 
        //echo $dsply ;
        $qstn = mysqli_query($con,"SELECT * FROM qstns where qid = '". $dsply ."'");
  
        $qstn = $qstn-&gt;fetch_array(MYSQLI_ASSOC);
  
         //echo $qstn['qname'] . "&lt;br&gt;";
         //echo $qstn['opta'] ."&lt;br&gt;";
         //echo $qstn['optb']."&lt;br&gt;";
         //echo $qstn['optc']."&lt;br&gt;";
         //echo $qstn['optd']."&lt;br&gt;";
  
          mysqli_close($con);
             ?&gt;
  
          &lt;body&gt;
  
       &lt;?php echo $qstn['qname'] ."&lt;br&gt;"; ?&gt;
       &lt;form action="prcs_ansr.php" method="post"&gt;
        &lt;input type="radio" name="rply" value="A" /&gt;&lt;?php echo $qstn['opta'] ; ?&gt;&lt;br /&gt;
       &lt;input type="radio" name="rply" value="B" /&gt;&lt;?php echo $qstn['optb']; ?&gt; &lt;br /&gt;
       &lt;input type="radio" name="rply" value="C" /&gt;&lt;?php echo $qstn['optc']; ?&gt;&lt;br /&gt;
       &lt;input type="radio" name="rply" value="D" /&gt;&lt;?php echo $qstn['optd']; ?&gt; &lt;br/&gt;
       &lt;input type="submit" value="previous"&gt;
       &lt;input type="submit" value="next"&gt;
        &lt;/form&gt;
  
  
       &lt;/body&gt;
        &lt;/html&gt;
  </code></pre>
  
  <p>I have two buttons in a single form and I want to process each one separately and for that I used isset() but it didn't work. The code for the next page is:</p>
  
  <pre><code>           &lt;?php
            session_start() ;
  
            $con=mysqli_connect("localhost","root","","QSTNS");
           if (mysqli_connect_errno()) {
           echo "Failed to connect to MySQL: " . mysqli_connect_error();
            }
  
           if (isset($_POST['previous'])) {
           if($_SESSION['cindx']&gt;0)
           $_SESSION['cindx']-=1;
           }
           if(isset($_POST['next']))
             {
           $res=mysqli_query($con, 'SELECT COUNT(*) FROM qstns');
           $row = mysqli_fetch_array($res);
           //echo $row[0];
  
           if($_SESSION['cindx']&lt;$row[0]-1)
           $_SESSION['cindx']+=1;
             }
          //echo 'here';
          header('Location: quiz_start.php');
  
      mysqli_close($con); 
       ?&gt;
  </code></pre>
  
  <p>Can anyone help?</p>