I'm using isset to check if a variable is set and not null, then I process it (e.g. send it via email or to a Google Spreadsheet). Sometimes I receive empty results, like if the variable is null or empty, not even an empty space. Why is this happening? Am I missing something?
if(isset($_POST["name"]) && isset($_POST["phone"])){
$name = $_POST["name"];
$phone = $_POST["phone"];
$message = "Nom: $name \nPhone: $phone \n";
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('[email protected]', 'Name From');
$mail->addAddress('[email protected]', 'Name To');
$mail->Subject = 'Subject';
$mail->Body = $message;
}
issetwill return true. Check it withisset($_POST["name"]) && empty($_POST["name"]).$a = "";thenisset( $a );will truns out betrueissetis not a good function to distinguish empty string