0
I’m trying to get a contact form, he didn’t have the code in php, only in html, and in the action function of the HTML code he sent to the site https://mobirise.com/.
Example - HTML As was:
<form action="https://mobirise.com/" method="post" data-form-title="INSCREVA-SE" class="">
<input type="hidden" value="xF2wyA3Am9XJfPWKPUBHNyYWvEGJICdaXxc9CFcjWrbWYGSdCv/fixi4T+1Vwwm0ndVitrKbaxtbtlwtaxG18eSbhyRi2OJog/+SyB+sMh6+6cl1NPdxVeoqfOgxNecW" data-form-email="true">
After creating the php code I removed from the HTML code the link that was in the action function(https://mobirise.com/) and replace by putting in place
the page ("enviar_email.php" ) I created with php code.
After making these changes in order to make the form send the message to the website email, I have the following problem: after filling the form and clicking send the message "Incorrect email!" appears. I need to solve this problem, so I can check if the php code will work and send the information correctly to the site.
HTML - part of the code I changed:
<form method="post" action="enviar_email.php" data-form-title="INSCREVA-SE">
HTML of Fomulário:
<!DOCTYPE html>
<html>
<head>
<section class="mbr-section" id="form1-0"
style="background-color: rgb(11, 66, 128); padding-top: 40px; padding-bottom: 40px;">
<div class="mbr-section mbr-section__container mbr-section__container--middle">
<div class="container">
<div class="row">
<div class="col-xs-12 text-xs-center">
<h3 class="mbr-section-title display-2"> </h3>
<h3 class="mbr-section-title display-2">CONTATE-NOS</h3>
<small class="mbr-section-subtitle">Deixe seu nome, e-mail e receba mais informações.</small>
</div>
</div>
</div>
</div>
<div class="mbr-section mbr-section-nopadding" >
<div class="container">
<div class="row">
<div class="col-xs-12 col-lg-10 col-lg-offset-1" data-form-type="formoid">
<div data-form-alert="true">
<div hidden="" data-form-alert-success="true"
class="alert alert-form alert-success text-xs-center">Muito Obrigado! Em breve
retornaremos.
</div>
</div>
<form method="post" action="enviar_email.php" data-form-title="INSCREVA-SE"> <!-- os dados serão enviados para a página que está definida no action=' ' -->
<div class="row row-sm-offset">
<div class="col-xs-12 col-md-6">
<div class="form-group">
<label for="form1-0-name" class="form-control-label style9">Nome</label>
<input type="text" class="form-control" name="name" required=""
data-form-field="Name" id="form1-0-name"> <!-- observa o name em cada um dos campos -->
</div>
</div>
<div class="col-xs-12 col-md-6">
<div class="form-group">
<label for="form1-0-email" class="form-control-label style9">E-mail</label>
<input type="email" class="form-control" name="email" required=""
data-form-field="Email" id="form1-0-email">
</div>
</div>
</div>
<div class="form-group">
<label for="form1-0-message" class="form-control-label style9">Mensagem</label>
<textarea class="form-control" name="message" rows="7" data-form-field="Message"
id="form1-0-message"></textarea>
</div>
<div>
<button type="submit" class="btn btn-warning">ENVIAR</button>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
Form Code - PHP
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sem título</title>
</head>
<body>
<?
//isset checa se o botão enviar - submit foi clicado e só vai disparar o email se for verdadeiro
if(isset($_POST['submit'])){
// email onde tu vai receber a mensagem
$destinatario = '[email protected]';
// pegando os dados do form...
$name = $_POST['name'];
$email = $_POST['email'];
$mensagem= $_POST['message'];
// headers que prepara a mensagem
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=utf-8" . "\r\n";
$headers .= "From: Site <[email protected]>" . "\r\n";
$headers .= "Reply-To: [email protected]" . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
/*abaixo contém os dados que serão enviados para o email
cadastrado para receber o formulário*/
$corpo = "Formulario Enviado\n";
$corpo .= "Nome: " . $name . "\n";
$corpo .= "E-mail: " . $email . "\n";
$corpo .= "Mensagem: " . $mensagem . "\n";
// envia o email... -->
$resposta = mail($destinatario,$headers,$corpo, $mensagem);
// volta para contato.html -->
header("Location: index.php");
}
?>
</body>
</html>
Message that appears when clicking send button
JS Code - Formoid
`code` jQuery(function(t){var e=function(){var e=("https:"==location.protocol?"https:":"http:")+"//formoid.net/api/push",a=function(){var e=(/MSIE (\d+)\./.exec(navigator.userAgent)||[0,0])[1]
return 8==e||9==e&&"file:"!=location.protocol?function(e,a){var n=new XDomainRequest,r=t.Deferred()
return n.open(a.type,e),n.onload=function(){r.resolve(this.responseText)},n.onerror=function(){r.reject()},n.send(a.data),r}:(t.support.cors=!0,t.ajax)}(),n=function(t,e){return t="__"+t+"__",e.length?(this[t]=e[0],this):this[t]},r=function(e,a,n){return t.each(n,function(t,n){e[n]=function(){return a[n].apply(a,arguments)}}),e},i=function(t){t=t||{},this.__email__=t.email||"",this.__title__=t.title||"",this.__data__=t.data||[]}
return i.prototype.email=function(t){return n.call(this,"email",arguments)},i.prototype.title=function(t){return n.call(this,"title",arguments)},i.prototype.data=function(t){return n.call(this,"data",arguments)},i.prototype.send=function(n,i){var o=r(t.Deferred(),this,["email","title","data","send"])
return i&&(i.call(this,o),"pending"!=o.state())?o:(a(e,{type:"POST",data:JSON.stringify({email:this.__email__,form:{title:this.__title__,data:arguments.length?n:this.__data__}})}).done(function(t){try{var e=JSON.parse(t)
e.error?o.reject(e.error):o.resolve(e.response)}catch(a){o.reject("Incorrect server response.")}}).fail(function(){var t="Failed to query the server. "
t+="onLine"in navigator&&!navigator.onLine?"No connection to the Internet.":"Check the connection and try again.",o.reject(t)}),o)},{Form:function(t){return new i(t)}}}(),a=function(e){if(e.checkValidity)return e.checkValidity()
var a=!0,n=t(e).val(),r=t(e).attr("type")
return n?a=!("email"===r&&!/^([^@]+?)@(([a-z0-9]-*)*[a-z0-9]+\.)+([a-z0-9]+)$/i.test(n)):t(e).attr("required")&&(a=!1),t(e)[(a?"remove":"add")+"Class"]("form-invalid"),a}
t('[data-form-type="formoid"]').each(function(){var n,r=t(this),i=r.is("form")?r:r.find("form"),o=r.find("[data-form-alert]"),s=r.is("[data-form-title]")?r:r.find("[data-form-title]"),l=r.find('[type="submit"]'),c=o.attr("data-success")||o.find("[data-form-alert-success]").html()
l.html('<span class="btn-text">'+l.html()+'</span><i class="btn-loader"></i>').click(function(){i.addClass("form-active")}),i.submit(function(d){if(d.preventDefault(),i.addClass("form-active"),!l.hasClass("btn-loading")){var f=!0,u=[]
n=n||e.Form({email:r.find("[data-form-email]").val(),title:s.attr("data-form-title")||s.text()}),o.html(""),r.find("[data-form-field]").each(function(){a(this)||(f=!1),u.push([t(this).attr("data-form-field")||t(this).attr("name"),t(this).val()])}),f&&(l.addClass("btn-loading").prop("disabled",!0),n.send(u).done(function(e){i.removeClass("form-active"),r.find("[data-form-field]").val(""),o.append(t('<div class="alert alert-form alert-success text-xs-center"/>').text(c||e))}).fail(function(e){o.append(t('<div class="alert alert-form alert-danger text-xs-center"/>').text(e))}).always(function(){l.removeClass("btn-loading").prop("disabled",!1)}))}})})})
Where does this message appear? After it sends the form or before?
– Sam
It does not send the form, when I click send it appears the message.
– Isabela
Appears where?...
– Sam
Hey Sam, I edited the question and added the screen print
– Isabela
This is some plugin that is doing this. You have to see all the JS code of the page.
– Sam
I think I found the JS code where it can contain the problem, has a JS indexed with the name formoid.min.js
– Isabela
Here’s a JS file that must be wrong for validation, and just see which JS file is being called and try without that same file.
– Ricardo