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


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.
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.
<?php

if(isset($_POST['field-name'])){

/* Do something */

}
form.php hosted with 💓 by GitHub
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
August 02, 2019
Labels:

Post a Comment

Note: Only a member of this blog may post a comment.

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget