Xav*_*avi 1 php forms email post redirect
我正在尝试从联系表单发送电子邮件,因此发送电子邮件正在工作但发送后我想重新定向到contact_formsuccess.php,但它没有重定向到那个页面,它仍然是相同的,可以任何一个如何谢谢你
<?php
$target_path = "/var/www/xxxxxx/cv/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
//print $target_path;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$name=$_POST['senderName'];
$email=$_POST['senderEmail'];
$mobile=$_POST['senderMobile'];
$company=$_POST['senderCompany'];
$inquiry=$_POST['inquiry'];
$message=$_POST['message'];
include 'class.phpmailer.php';
include 'class.smtp.php';
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
//$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "mail.authsmtp.com";
$mail->Port = "25"; // or 587
$mail->IsHTML(true);
$mail->Username = "xxxxx";
$mail->Password = "xxxxx";
$mail->SetFrom("xxx@xxxxxxx.com");
$mail->Subject = $inquiry;
$mail->Body = "Name:$name"."<br/><br />"."E-mail:$email"."<br/><br/>"."Mobile:$mobile"."<br/><br/>"."Company:$company"."<br/><br/>".$message;
$mail->AddAttachment($target_path);
$mail->AddAddress('xxxxxxxxxx@gmail.com');
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
header('Location: contact_formsuccess.php');
}
?>
Run Code Online (Sandbox Code Playgroud)
尽量把header('Location: contact_formsuccess.php');
后
$mail->AddAddress('xxxxxxxxxx@gmail.com');
也许就会作品