Skip to main content
Post Closed as "Duplicate" by mickmackusa php
edited title
Link
Dharman
  • 33.9k
  • 27
  • 106
  • 157

PHP, issues when submitting post form Check if a POST value is empty

Source Link
user12736866
user12736866

PHP, issues when submitting post form

I want to check if the post if filled or not (post variable empty or not) I'm using "isset", and it just does not seem to work, everytime i submit the form it says filled even when the form is not filled.

PHP code :

<?php if (isset($_POST["submit"])) { echo "filled"; } else { echo "not filled"; } ?> 

HTML code :

<form method="post"> <input type="text" name="username" /><br><br> <input type="submit" name="submit"> </form> 

when i printed $_POST, it says :

[username] => [submit] => Submit