How to refresh form after submit in PHP

How to refresh form after submit in PHP

index.php

<html>
  <title>Codelizar Form</title>
  <head>
    <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
    <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
  </head>
  <body>
    <form method="POST" action="">
      <div class="row">
          <div class="col-md-3 form-group">
            <label for="username"></label>
            <input type="text" value="" name="username" class="form-control">
          </div>
          <div class="col-md-3 form-group">
            <label for="password"></label>
            <input type="text" value="" name="password" class="form-control">
          </div>
          <div class="col-md-3 form-group">
            <button name="btn_submit" type="submit" class="btn btn-info">Submit Me</button>
          </div>
      </div>
    </form>
  </body>
</html>

<?php
  
  if(isset($_POST['btn_submit'])){
   $username = $_REQUEST['username'];
   $password = $_REQUEST['password'];

   // Here run you sql insert query and apply code for form refresh after successfully insertion 
   echo "<meta http-equiv='refresh' content='0'>"; // form refresh code

 }
  
?>

 

Leave a Reply

Your email address will not be published. Required fields are marked *