While submitting this to my local host, "warning : undefined array key "required" (php)

910 Views Asked by At

Warning: Undefined array key "Required" on line 15

Here's my code.

$RequiredMail = $Required = "";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
    if (filter_var($_POST["Required"])) {  <--------Line 15
        $RequiredMail = "De email dient ingevult te worden";
    } else {
        $Required = test_input($_POST["E-mail"]);
    }

it might be obvious to some, but i'm bashing my head against a wall. i haven't made an array yet and don't know how to implement it inside of my code.

If there are any videos / books / recommendations all is appreciated. Could someone explain this to me as if i am a dummy?

1

There are 1 best solutions below

2
On

Is this just typo? Shouldn't you be testing for $_POST["E-mail"] instead of $_POST["Required"] on line 15? So try:

$RequiredMail = $Required = "";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
    if (filter_var($_POST["E-mail"])) {
        $RequiredMail = "De email dient ingevult te worden";
    } else {
        $Required = test_input($_POST["E-mail"]);