Extra Catchy

Fix: Undefined Index Error PHP [$_POST and $_GET Methods]

Posted in: PHP

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.


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.

Let’s know how to fix this.

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.

Just change the value of $_POST to your own form field.

That’s it.

If you have any error or questions, ask in the comment box.

Don’t forget to share this Solution of Undefined Index Error