繁体   English   中英

PHP下载代码不起作用

[英]PHP download code not working

有人可以告诉我为什么这段代码不起作用。 我希望用户提交用户数据后下载文件“ tokina.pdf”,如果任何字段为空,页面将重定向到登录页面。 但是,即使用户数据不正确,该位代码也始终会启动下载过程。

谢谢

<?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');         

}





?>

如果任何字段为空

所以不是AND而是OR

if ($mail == "" && $name == "" && $number == "")

应该

if ($mail == "" OR $name == "" OR $number == "")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM