title: I have to refresh my php page after form submission to execute the code and display output
body: <p>Form Submission Code</p>
  
  <pre><code>&lt;form action="search.php" method="POST" id="form2"&gt;
    &lt;input type="text" name="Sr_no" required="true" placeholder="Enter Serial Number"&gt;&lt;br&gt;
    &lt;input type="submit" value="Check Status" name="ss"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My search.php</p>
  
  <pre><code>&lt;?php
  
      $connect=mysqli_connect("localhost","root", "" ,"mydatabase");
      $Sr_no = $_POST["Sr_no"];
  
      $status_check = "SELECT verified FROM r_concession_forms WHERE id = '$Sr_id' LIMIT 1";
      $s_check = $connect-&gt;query($status_check);
      $s_value = $row = $s_check-&gt;fetch_assoc();
  
      if($s_value["verified"] == "0")
      {
          echo "&lt;script&gt;
              alert('Not Issued/Verified');
              window.location.href='index.php';
          &lt;/script&gt;" ;
      }
      elseif($s_value["verified"] == "1"){
          echo "&lt;script&gt;
              alert('Issued and Verified');
              window.location.href='index.php';
              &lt;/script&gt;";
      }
      else{
          echo "&lt;script&gt;
              alert('No Such Form Exists');
              window.location.href='index.php';
          &lt;/script&gt;";
      }
  ?&gt;
  </code></pre>
  
  
  
  <p>Output:
  My Input first to check if that "id" exists in database</p>
  
  <p><a href="https://i.stack.imgur.com/2GCaU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2GCaU.png" alt="Input on first page"></a></p>
  
  <p>There is no alert box as expected, but the URL shows search.php, but no alert box displayed</p>
  
  <p><a href="https://i.stack.imgur.com/juEyq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/juEyq.png" alt="No alert box"></a></p>
  
  <p>After refreshing the page, the alert box starts working</p>
  
  <p><a href="https://i.stack.imgur.com/v41e5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v41e5.png" alt="After refresh it works"></a></p>
  
  <p>The designing of page is by JavaScript </p>