ARUN CYBER SECURITY Posted July 29, 2020 Share Posted July 29, 2020 sir I am arun .And I have desigining a form and a have validating with php . but if I enter just space in all my form fields my validation dosen't works Please can give a solution html <input type="text" placeholder="name" name="fname"/> if($_SERVER["REQUEST_METHOD"]=="POST"){ $name=htmlspecialchars($_REQUEST["fname"]); $dat =htmlspecialchars($_REQUEST["dat"]); echo $name; if(empty($name)){ echo"name is empty"; } else{ echo $name; } 2020-07-15 23-15-35.mp4 2020-07-15 23-15-35.mp4 Link to comment Share on other sites More sharing options...
Funce Posted July 29, 2020 Share Posted July 29, 2020 This is because " " is not an empty string, and therefore passes your validation. Link to comment Share on other sites More sharing options...
dsonesuk Posted July 30, 2020 Share Posted July 30, 2020 Use trim() to trim white spaces from ends, once trimmed it will be empty. Link to comment Share on other sites More sharing options...
Sherin Posted February 19, 2021 Share Posted February 19, 2021 You can pass single quote ' ' in REQUEST_METHOD. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now