我使用了自由的PHPMailer从我的表单发送电子邮件,但是问题是,我希望将键入的数据插入到我的数据库中,这是没有发生的,这是唯一的发生的情况是,它仅插入空值,并且不显示我发出的成功消息。
Php:
<?php
$result="";
if(isset($_POST['submit'])){
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail -> Host='smtp.gmail.com';
$mail->Porto = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure='tls';
$mail->Username='****';
$mail->Password='****';
$mail->setFrom($_POST['EmailReser']);
$mail->addAddress('filipajoao1933@gmail.com');
$mail->addReplyTo($_POST['EmailReser']);
$mail->isHTML(true);
$mail->Subject='Reversa';
$mail->Body='<h1>Name:'.$_POST['NomeReser'].'<br>Email:'.$_POST['EmailReser'].'<br>Message: '.$_POST['MensagemR'].'</h1>';
if(!$mail->send()){
$result="Something went wrong. Please try again";
}
else{
$result="Thanks".$_POST['NomeReser']."for contacting us. We´ll get back to you soon!";
}
$sql = "INSERT INTO Reservas (NomeReser, EmailReser, MensagemR) VALUES ('$Nome','$Email', '$Mensagem')";
$res=$lig->query($sql);
}
?>