I want to send user entered form data to mysql via php using get.
  <form  action="formtosql.php" method="get">
  <div class="row">
  <div class="form-group col-md-4">
    <label for="001">Student name:</label>
    <input type="text" class="form-control" id="001" name="sname">
  </div>
  </div>
  
<div class="row">
<div class="form-group col-md-4">
    <label for="002">Status:</label>
    <input type="text" class="form-control" id="002" name="sstatus">
  </div>
</div>
 
  <button type="submit" class="btn btn-primary">Submit</button>
 
</form>
php code looks like this:
 <?php
    if ($_SERVER['REQUEST_METHOD'] == 'GET'){
        $name = $_GET['sname'];
        $stat = $_GET['sstatus'];
        
        
      
      // Connecting to the Database
      $servername = "localhost";
      $username = "root";
      $password = "";
      $database = "exam";
      // Create a connection
      $conn = mysqli_connect($servername, $username, $password, $database);
      // Die if connection was not successful
      if (!$conn){
          die("Sorry we failed to connect: ". mysqli_connect_error());
      }
      else{ 
       
        $sql = "INSERT INTO `estatus` (`name`, `status`, `date`) VALUES ('$name', '$stat', current_timestamp())";
        $result = mysqli_query($conn, $sql);
    
?>
In php im getting an error while using get:
Notice: Undefined index: sname in C:\xampp\htdocs\helloworld\formtosql.php
Notice: Undefined index: sstatus in C:\xampp\htdocs\helloworld\formtosql.php
This error does not occur if I am using Post.
 
     
    