Could some one please tell me why this bit of code is not working. I w开发者_如何转开发ant the user to download a file "tokina.pdf" after he has submitted user data, the page redirects to the login page if any field is empty. But the bit of code always starts a download process even if user data is incorrect.
Thank you
<?php
$name = $_POST["name_first"];
$mail = $_POST['email'];
$number = $_POST['phone_number'];
echo "Name : $name";
echo '<br>';
echo "Email-ID : $mail";
echo '<br>';
echo "Phone-Number : $number";
$email_message = "first name: {$name} email is {$mail} number is {$number} ";
mail('vinferrari@gmail.com', 'Form Response', $email_message);
if ($mail == "" && $name == "" && $number == "")
{
header('Location: m1.php'); (redirect to page where user data is collected)
echo "error in submitted data";
}
else
{
//download.php
//content type
header('Content-type: application/pdf');
//open/save dialog box
header('Content-Disposition: attachment; filename="tokina.pdf"');
//read from server and write to buffer
readfile('tokina.pdf');
}
?>
if any field is empty
So it's not AND but OR
if ($mail == "" && $name == "" && $number == "")
shoud be
if ($mail == "" OR $name == "" OR $number == "")
精彩评论