Reiterating my comment, don't suppress the warnings using @
, fix the script so the error doesn't occur. Use the empty() function to make sure it's filled. You can combine that with trim() to remove spaces and if it's and email, use filter_var($email,FILTER_VALIDATE_EMAIL) to verify it's a valid email pattern.
Example:
# Check the email is set and trim it
$email = (isset($_REQUEST['urEmail']))? trim($_REQUEST['urEmail']) : false;
# Check the recaptcha is set and trim it
$recap = (isset($_REQUEST['g-recaptcha-response']))? trim($_REQUEST['g-recaptcha-response']) : false;
# If either are empty
if(empty($email) || empty($recap)) {
$errorsAndAlerts .= "No email entered!<br/>\n";
}
# If both filled but invalid email
elseif(!filter_var($email,FILTER_VALIDATE_EMAIL)) {
$errorsAndAlerts .= "Email invalid!<br/>\n";
}
//etc...
At any rate, as @Don'tPanic mentions, make sure you have error reporting on ini_set('display_errors',1); error_reporting(E_ALL);
, but I suspect you do since you are suppressing the errors/warnings with @
.
One final note, to alleviate some repetition, I would maybe think about saving errors to an array and imploding them at the end:
# Save all errors using the push
# (mine are in a line, but yours would be throughout your script)
$error[] = "No email entered";
$error[] = "Invalid request";
$error[] = "Invalid email";
$error[] = "Poor penmanship";
# Implode with the glue when you want to output them
echo implode('!<br />'.PHP_EOL,$error).'!';