0
<?php
include_once('admin/dbcon.php');
if(isset($_POST["submit"])=="Apply Now")
{
//$resume='';
//$photos='';
$fullname = strip_tags($_POST["fullname"]);
$address = strip_tags($_POST["address"]);
$state = strip_tags($_POST["state"]);
$city = strip_tags($_POST["city"]);
$mobile = strip_tags($_POST["mobile"]);
$email = strip_tags($_POST["email"]);
$username="xxxxxxx";
$apply_for = strip_tags($_POST["apply_for"]);
/*Resume file uploaded*/
$allowedExts = array("pdf", "doc", "docx");
$extension = end(explode(".", $_FILES["up_resume"]["name"]));
if ($_FILES["up_resume"]["type"] == "application/pdf" ||
$_FILES["up_resume"]["type"] == "application/msword" ||
$_FILES["up_resume"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
{
$type =substr($_FILES["up_resume"]["name"],strrpos($_FILES["up_resume"]["name"], '.') + 1);
$resume = "Resume_".time().".".$type;
move_uploaded_file($_FILES["up_resume"]["tmp_name"], "admin/upload/".$resume);
}
else
{
header("Location:apply-now.php?rm=Invalid file, Please upload your updated resume!!");
}
/*Photo uploaded here*/
$allowedExts1 = array("gif", "jpeg", "jpg", "png");
$extension1 = end(explode(".", $_FILES["profiel_photos"]["name"]));
if ($_FILES["profiel_photos"]["type"] == "image/gif" || $_FILES["profiel_photos"]["type"] == "image/jpeg" ||
$_FILES["profiel_photos"]["type"] == "image/pjpeg" || $_FILES["profiel_photos"]["type"] == "image/png" || $_FILES["profiel_photos"]["type"] == "image/jpg")
{
$type1 =substr($_FILES["profiel_photos"]["name"],strrpos($_FILES["profiel_photos"]["name"], '.') + 1);
$photos = "prf_img_".time().".".$type1;
move_uploaded_file($_FILES["profiel_photos"]["tmp_name"], "admin/upload/".$photos);
}
else
{
header("Location:apply-now.php?pic=Invalid file,Please upload your updated photos!!");
}
$status = "INSERT INTO `caretel`.`tb_career` (`FullName`, `Address`, `State`, `City`, `ContactNo`, `Email`, `Resume`, `ProfileImg`, `ApplyFor`) VALUES ('$fullname', '$address', '$state', '$city', '$mobile', '$email', '$resume', '$photos', '$apply_for')";
if(mysql_query($status))
{
require_once('include/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP(); //
$mail->Host = "smtp.gmail.com";
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->Port = 25;
$mail->Username = "[email protected]";
$mail->Password = "XXXXXXX";
//$mail->SMTPSecure = "ssl";
$mail->SMTPSecure = "tls";
$mail->AddAddress($email,"Guest");
$mail->SetFrom("[email protected]","XXXXXXXX");
$mail->Subject = "New Applicat Applyed for ".$apply_for;
$body = 'html';
$mail->MsgHTML($body);
$mail->AddAttachment("admin/upload/".$resume); // attachment
$mail->AddAttachment("admin/upload/".$photos); // attachment
if($mail->Send())
{
echo "hi";
header("Location:apply-now.php?msg=Thank you for Apply. We will be in touch with you very soon!!");
exit;
}else{
header("Location:apply-now.php?msg=We encountered an error sending your mail");
exit;
}
}
}else{
echo "dfsdfsdfsdf ";
}
?>
邮件不发送,而不是重定向到应用,now.php页我也我们端口使用SSL 465和TLS 587和不显示邮件发送只能重定向后的任何类型的错误在我的动作php页面上,这个代码有什么问题请帮助我 谢谢失败邮件发送后重定向,而不是发送邮件
负载PHPMailer的。要诊断这一点,请在使用重定向之前对发送进行整理 - 它们会阻止您看到调试输出。对于gmail,你肯定应该在587上使用tls。如果你打算使用调试输出,我建议你设置'$ mail-> SMTPDebug = 3;'来更全面地了解发生了什么。 – Synchro 2014-09-04 06:57:03
您应该将脚本分解为多个部分并独立测试(函数或类)。例如用虚拟数据测试邮件程序。自己测试重定向。测试表单提交没有附件,最后一切都在一起。我建议使用像Symfony2 \ HttpFoundation这样的库来处理请求和重定向,并使用SwiftMailer发送电子邮件。这些库很好地维护和记录。最后,使用参数化查询将数据写入数据库,您目前正在执行的方式将允许任何人执行SQL注入攻击。 – Onema 2014-09-04 06:59:24