I'm trying to validate a form, and if empty would show an error that it is required. My problem is, even if i did not submitted a form yet, it already checks if the variable is empty. I need help.
here is the php above my html document
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST"){
// The form has been submitted
// We can do stuff here
$email = $_POST['email'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$password = $_POST['password'];
$password_confirm = $_POST['password_confirm'];
if(empty($email) === true){
$error = 'Email address is required' ;
}
}
?>
Aucun commentaire:
Enregistrer un commentaire