I have a simple form
<!DOCTYPE html>
<html>
<head>
<script>
//prevents website to send another POST request when user refreshes website
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
</head>
<body>
<div class="content">
<form method="post">
<label>StudentID : </label>
<input type="text" name="studentid">
<p id="errorMessage"></p>
<input type="submit" value="Book Meeting">
</form>
</div>
</body>
</html>
And a short snippet of my php code:
<?php
//must be connected to the database before running the website
require_once("connection.php");
//if the form is submitted(to search for student id)
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$studentid = $_POST['studentid'];
//if the input is not empty
if(!empty($studentid))
{
Whenever I try to submit the form with any input, the if($_SERVER['REQUEST_METHOD'] == "POST")
does not detect POST method, however it works when I submit the form with an empty input. I was debugging the whole night and still could'nt figure out the problem. Any help will be appreciated!!