Obviously I know that array_key_exists
is not giving a false positive. I'm doing something wrong. I just wanted to grab your attention. :)
Seriously though. I am doing this as an exercise.
Here is my code:
<?php
$error = "";
if($_POST)
{
if (!array_key_exists('email',$_POST)) {
$error .= "<p>You did not submit an e-mail address. Please try again.</p>";
}
if (!array_key_exists('password',$_POST)) {
$error .= "<p>You did not submit a password. Please try again.</p>";
}
echo $error;
print_r($_POST);
}
?>
When I don't submit either email or password, echo $error
outputs nothing. print_r($_POST)
outputs whatever I sent.
What am I missing here?
You did not submit an e-mail address. Please try again.
"; – Sivaraj S Oct 17 '17 at 14:58