The problem is when I use
$fname = isset($_POST['fname']) ? $_POST['fname'] : 'sample';
die($fname);
in PHP side after form submission with filled fname field getting output exactly what I filled, after submission with unfilled fname input field, getting output ABSOLUTELY NOTHING. Used code !empty instead
$fname = !empty($_POST['fname']) ? $_POST['fname'] : 'sample';
die($fname);
after submission with unfilled fname input field, getting output sample.
That’s because the ‘fname’ variable is sent anyway, it’s just empty but sent!
Try changing your form method from POST to GET and you’ll see by yourself.