我正在使用PHPmailer发送邮件。我在每个网站上使用相同的脚本。但突然之间,标题重定向并不起作用,我真的不知道为什么......
下面的代码剪切,我感谢每一个建议,谢谢!
编辑:已添加完整代码
$(document).ready (function () {
var url = "https://api.nasa.gov/neo/rest/v1/feed?start_date=2015-09-07&end_date=2015-09-08&api_key=DEMO_KEY";
$.ajax({
url: url,
success: function (data) {
// you can't use dot syntax with numbers:
// console.log (thing.123);
// try this instead:
var neos = data.near_earth_objects['2015-09-08'];
// and to find the hazardous asteroids:
var hazardous_neos = neos.filter (function (d) {
// return true to add d to the array returned from filter()
// return false to NOT add d to the array from filter()
// if we want hazardous asteroids then
// since is_potentially_hazardous_asteroid is a
// boolean where true means it's hazardous then
// we can simply return its value
return d.is_potentially_hazardous_asteroid;
// if we want NON-hazardous asteroids we can do:
//return d.is_potentially_hazardous_asteroid == false;
});
console.log (hazardous_neos);
}
});
});
答案 0 :(得分:1)
只需使用此代码:
<?php
require_once("phpmailer/class.phpmailer.php");
if (isset($_POST['odeslat'])){
$allowedExts = array("doc", "docx", "xls", "xlsx", "pdf");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
$jmeno = $_POST['jmeno'];
$email = $_POST['email'];
$telefon = $_POST['telefon'];
$text = $_POST['zprava'];
$mail = new PHPMailer();
//From email address and name
$mail->CharSet = "UTF-8";
$mail->From = "info@mail.com";
$mail->FromName = "MAIL";
//To address and name
$mail->addAddress("yourmail@mail.com"); //Recipient name is optional
$mail->AddAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']);
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Server email";
$mail->Body = "<p><strong>Jméno:</strong> $jmeno</p>
<p><strong>E-mail:</strong> $email</p>
<p><strong>Telefon:</strong> $telefon</p>
<p><strong>Text:</strong> $text</p>
";
$mail->AltBody = "Jméno: $jmeno \n
E-mail: $email \n
Telefon: $telefon \n
Text: $text\n
";
if(!$mail->send())
{
echo '<script type="text/javascript">';
echo 'window.location.href = "http://mypage.com/dotaznik.php?e=1"';
echo '</script>';
}
else
{
echo '<script type="text/javascript">';
echo 'window.location.href = "http://mypage.com/dotaznik.php?o=1"';
echo '</script>';
}
}
?>