How do i fix "undefined index" in php?

Example:

$value = $_POST["non_existent_key"];
This error means you're trying to access an array key that doesn't exist.

Solution:

if (isset($_POST["non_existent_key"])) {
    $value = $_POST["non_existent_key"];
}

Beginner's Guide to PHP