0
I have a form included within a modal window. My question is how it should be done to appear a completed sending message within the modal window after the form is sent, all this process would need to be done within the same page, without updating the page.
All code: CSS, HTML and Jquery is in codepen: http://codepen.io/flashpremium/pen/KpzqoJ/
Php code of the form
header('Content-Type: text/html; charset=utf-8');
// from the form
$name = trim(strip_tags($_POST['nome']));
$email = trim(strip_tags($_POST['email']));
$assunto = htmlentities($_POST['assunto']);
$mensagem = htmlentities($_POST['mensagem']);
// set here
$subject = "Nova mensagem no formulário";
$to = '[email protected]';
$body = <<<HTML
<table bgcolor="#EEEEEE" align="center" border="1" cellpadding="0" cellspacing="0" width="600" style="font-family: arial; border: 1px solid #f4f4f4; border-radius: 5px;">
<tr>
<td bgcolor="#fff" style="text-align: left; padding: 10px; margin: 5px 5px 5px 5px; color: #222; font-weight: bold; border: 1px solid #f4f4f4; font-weight: 100; font-size: 14px;">
Dados
</td>
<td bgcolor="#fff" style="text-align: left; padding: 10px; margin: 5px 5px 5px 5px; color: #222; font-weight: 100; border: 1px solid #f4f4f4; font-size: 14px;">
Mensagem
</td>
</tr>
<tr>
<td bgcolor="#fff" style="padding: 10px;border: 1px solid #f4f4f4;color: #33b0f7; font-size: 14px;">
Nome
<td bgcolor="#fff" style="text-align: left; padding-left: 5px;border: 1px solid #f4f4f4; font-size: 14px;">$name</td>
</tr>
<tr>
<td bgcolor="#fff" style="padding: 10px;border: 1px solid #f4f4f4;border: 1px solid #f4f4f4; color: #33b0f7; font-size: 14px;">
E-mail
<td bgcolor="#fff" style="text-align: left; padding-left: 5px;border: 1px solid #f4f4f4; font-size: 14px;">$email</td>
</td>
</tr>
<tr>
</tr>
<tr>
<td bgcolor="#fff" style="padding: 10px;border: 1px solid #f4f4f4; font-size: 14px;">
Mensagem:
<td bgcolor="#fff" style="text-align: left; padding: 5px; height: 400px;border: 1px solid #f4f4f4; font-size: 14px;">$message</td>
</td>
</tr>
</tr>
</table>
HTML;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
// send the email
mail($to, $subject, $body, $headers);
// redirect afterwords, if needed
header('Location: enviado');
Thank you for the answer! I’m having doubts about how to put the success message in the sending inside a div that should only appear after the email is sent.
– the flash