ARUN CYBER SECURITY 0 Posted July 29, 2020 Report 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 Quote Link to post Share on other sites
Funce 42 Posted July 29, 2020 Report Share Posted July 29, 2020 This is because " " is not an empty string, and therefore passes your validation. Quote Link to post Share on other sites
dsonesuk 921 Posted July 30, 2020 Report Share Posted July 30, 2020 Use trim() to trim white spaces from ends, once trimmed it will be empty. Quote Link to post Share on other sites
Sherin 1 Posted February 19 Report Share Posted February 19 You can pass single quote ' ' in REQUEST_METHOD. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.