doutao6653 2014-04-15 10:49
浏览 57
已采纳

表格不重定向或发送电子邮件

Having an issue with my mailer script. When an email is sent it doesn't redirect to my chosen page it sits on mail.php which os the logic file. Having some issues understanding what the top section is asking me for too.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<?php
require 'c:\php\includes\PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.website.com'; // Specify main and backup server
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'my@website.com';                            // SMTP username
$mail->Password = '******';                         // Enable encryption, 'ssl' also accepted
$mail->Port = 25;

$mail->From = 'http://iamdanbarrett.com';
$mail->FromName = 'Contact Form';

$mail->addAddress('iamdanbarrett.com');               // Name is optional


$mail->WordWrap = 50;                                 // Set word wrap to 50 characters

$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'General Enquiries';

$mail->Body    = "<html><body>Name: " . $_POST["Name"] . "<br><br>Email: " . $_POST["Email"] . "<br><br>Message: " . $_POST["Message"];

// $mail->Body    = 'Details below:<br><hr><br><br><b>Shortlist:</b><br>' . $_POST["strShortlist"] . '<br><br><b>Company:</b> ' . $_POST["strCompany"] . '<br><br><b>Full Name:</b> ' . $_POST["strFullname"] . '<br><br><b>Email:</b> ' . $_POST["strEmail"] . '<br><br><b>Contact No:</b> ' . $_POST["strContactNo"] . '<br><br><b>No of People:</b> ' . $_POST["strNoOfPeople"] . '<br><br><b>Start Date:</b> ' . $_POST["strDate"] . '<br><br><b>Requirements:</b> ' . $_POST["strRequirements"] . '<br><br><b>Other:</b> ' . $_POST["strOther"] . '<br><br><b>Salesperson:</b> ' . $_POST["strSalesperson"];

if(!$mail->send()) {
   echo '';
   echo '';
   exit;
} else {

}

?>

</head>

<body>

<script>
  $( document ).ready(function() {
    window.location.href = "http://iamdanbarrett.com/;
  });
</script>
  • 写回答

2条回答 默认 最新

  • douyasihefu6214 2014-04-15 10:52
    关注

    Why do you have to bring Javascript in here ? Use the PHP's header() instead.

    if(!$mail->send()) {
            die("Mail was not sent!");
    } else {
        header("location:http://iamdanbarrett.com/");
        exit;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输