1
I have a form that I am passing via post to the phpmailer script, after sending it redirects to another page saying if the form was sent or not, but does not return the form page, I tried to do via ajax and could not:
would have some way to send the form by php and return the page only with php?
My form:
<div class="row contact">
<div class="col-lg-6 col-sm-6 ">
<form id="form" method="post" action="mail/phpmailer.php">
<input type="text" class="form-control" placeholder="Nome completo:" name="nome">
<input type="text" class="form-control" placeholder="E-mail:" name="email">
<input type="text" class="form-control" placeholder="Número para contato:" name="num">
<textarea rows="6" class="form-control" placeholder="Digite sua mensagem" name="msg"></textarea>
<input type="button" class="btn btn-success" name="enviar" value="Enviar">
</form>
</div>
</div>
Configuration of Phpmailer:
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->setLanguage('pt');
$from = '[email protected]';
$fromName = '-';
$host ='smtp.umbler.com';
$username ='[email protected]';
$password ='-';
$port =587;
$secure =false;
$mail->isSMTP();
$mail->Host = $host;
$mail->SMTPAuth = true;
$mail->Username = $username;
$mail->Password = $password;
$mail->Port = $port;
$mail->SMTPSecure = $secure;
$mail->From = $from;
$mail->FromName = $fromName;
$mail->addReplyTo($from, $fromName);
$mail->addAddress('[email protected]', '-');
$mail->isHTML(true);
$mail->CharSet = 'utf-8';
$mail->WordWrap = 70;
$mail->Subject = 'Contato ';
$mail->Body = 'Nome: ' .$_POST['nome'] . 'Email: ' . $_POST['email'] . 'Numero: ' . $_POST['num'];
$mail->AltBody = $_POST['msg'];
$send = $mail->Send();
if($send)
echo 'E-mail enviado com sucesso!';
else
echo 'Erro : '.$mail->ErrorInfo;
?>
This way after pressing send it goes to the phpmailer.php page and informs whether it was sent or not, but does not return to the form page...
How do you set up email sending? You want it to redirect to some page depending on whether the email is sent or not?
– Miguel
I edited the question, see how this my code
– Ricardo Feller