Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 表单提交后重定向_Php_Jquery_Email - Fatal编程技术网

Php 表单提交后重定向

Php 表单提交后重定向,php,jquery,email,Php,Jquery,Email,我正在尝试在用户输入电子邮件后重定向用户。我可以发送带有附件的电子邮件,但无法将用户重定向到thankyou.html。如果我取消对硬编码值的注释并使用它,则重定向工作正常。不知道我做错了什么。感谢您的帮助 这是我的php文件: <?php //form variables $to = $_POST['userEmail']; $user_name = $_POST['userName']; $subject = $_POST['subject']; $fname = $_POST['f

我正在尝试在用户输入电子邮件后重定向用户。我可以发送带有附件的电子邮件,但无法将用户重定向到thankyou.html。如果我取消对硬编码值的注释并使用它,则重定向工作正常。不知道我做错了什么。感谢您的帮助

这是我的php文件:

<?php

//form variables
$to = $_POST['userEmail'];
$user_name = $_POST['userName'];
$subject = $_POST['subject'];
$fname = $_POST['filename'];
$mailcopyfile = $_POST['backupfile'];
//$subject = 'Templage from us';
//$fname = 'somefile.xlsx';
//$mailcopyfile = 'somefile.csv';

// common for all landing page emails
$from_name = 'MyCompany LLC';
$from_mail = 'admin@mycompany.com';
$now = date('Y-m-d H:i:s');
$num = md5(time());

$message  = "<html><body>";
$message .= "<span>Dear " . $user_name . ",</span>";
$message .= "<table><tr><td>Thank you for your interest in our company.</td></tr>";
$message .= "<tr><td>Here is the template you requested.</td></tr>";
$message .= "<tr><td>&nbsp;</td></tr>";
$message .= "<tr><td>Regards,</td></tr>";
$message .= "<tr><td>Our Team</td></tr>";
$message .= "</table>";
$message .= '<a href="http://www.mycompany.com"><img src="http://mycompany.com/Images/logo.jpg" alt="MyCompany LLC"></a>';
$message .= "</body></html>";

//File  open
$fp = fopen($fname, "rb");
$upload_size=filesize($fname);
$file = fread($fp, $upload_size);

$file = chunk_split(base64_encode($file));
fclose($fp);
$upload_type=filetype($fname);

//Normal headers

$headers   = "From: ".$from_name." <".$from_mail.">\r\n";
$headers  .= "Reply-To: ".$from_mail."\r\n";
$headers  .= "MIME-Version: 1.0\r\n";
$headers  .= "Content-Type: multipart/mixed; ";
$headers  .= "boundary=".$num."\r\n";
$headers  .= "--" .$num. "\r\n";

// With message

$headers .= "Content-Type: multipart/alternative; boundary=";
$headers .= $num. "\r\n";
$headers .= "--" .$num. "\r\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\r\nContent-Transfer-Encoding: 7bit\r\n";
$headers .= "Thanks for your interest in our company. Here is the template you requested. Thanks Our Team\r\n";
$headers .= "--" .$num. "\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\r\n";
$headers .= $message."\r\n\r\n";
$headers .= "--".$num."\r\n";

// Attachment headers

$headers  .= "Content-Type:".$upload_type."; ";
$headers  .= 'name="'.$fname.'"'. "\r\n";
$headers  .= "Content-Transfer-Encoding: base64\r\n";
$headers  .= "Content-Disposition: attachment; ";
$headers  .= 'filename="'.basename($fname).'"' . "\r\n";
$headers  .= $file."\r\n";
$headers  .= "--".$num."--";


//send the email
$mail_sent = @mail( $_POST['userEmail'], $subject, "", $headers );
//$mail_sent = @mail( 'myemail@hotmail.com', $subject, "", $headers );

if($mail_sent){
    $fp = fopen($mailcopyfile, "a");
    fputs($fp, $now . "\t" . $user_name . "\t" . $_POST['userEmail'] . "\t\n" );
    //fputs($fp, $now . "\t" . $user_name . "\t" . 'myemail@hotmail.com' . "\t\n" );
    fclose($fp);
    header('Location: Thankyou.html', true);
    exit;
}
?>


文件路径是否正确?您是否尝试了Thankyou.html的绝对路径?是的,我尝试了绝对路径,但仍然没有work@srrvnn这是我尝试的标题('Location:',true);这个论坛中的一些答案建议使用echo和JS来更改href,这对我也不起作用。