if(hasPost()) { $name = $_POST['name']; $email = $_POST['email']; // process form data }
if(!hasPost()) { header('Location: /form-page.php'); exit(); }In this example, we are checking whether the request is not a POST request. If it is not, we redirect the user back to the form page. Package/Library: This functionality is part of the core PHP language and does not require any external package or library.