In PHP when we try to use these 2 method $_POST and $_GET to get users filled form data in our website, we always get Undefined Index Error.
Why?
Because when we open the form page or the page where we put those 2 methods, it’s not have any value set or is NULL…
…so when the users filled the form and submit, the error will remove, because it will get the value.
Fix Undefined Index Error PHP
It’s simple, you just need to use isset() function.What isset() does?
Isset function determine if a variable is set and is not
NULL
Here is the code example that will fix undefined index error.
<?php |
if(isset($_POST['field-name'])){ |
/* Do something */ |
} |
That’s it.
Don’t forget to share this Solution of Undefined Index Error
Post a Comment
Note: Only a member of this blog may post a comment.