-
Conteúdo Similar
-
Por jrdesign
OLÁ,TUDO BEM? O MEU HTML ESTÁ ASSIM. VEJA ABAIXO. ERA PRA ME ENVIAR UM EMAIL COM OS DADOS PREENCHIDOS E LIVERAR O DONLOAD, MAS NÃO CONSEGUI... O E-MAIL NÃO CHEGA, MAS PELO MENOS LIBERA O DOWNLOAD.
<div class="contact-form2">
<form method="post" action="baixa2.php" name="contatos" onSubmit="return Valida();">
<ul class="list-unstyled">
<p>
<input name="nome" required type="my_name" class="textbox right" value="Nome" onfocus="if(this.value == 'Nome') this.value='';"></p>
<p>Formato Telefone: (xx)-xxxx-xxxx</p>
<p>
<input name="telefone" pattern="^\((\d{2})\)\s?(\d{4,5}\-?\d{4})$" type="tel" required class="textbox right" value="Telefone" onfocus="if(this.value == 'Telefone') this.value='';"></p>
<p>
<input name="email" type="email" required class="textbox right" value="E-mail" onfocus="if(this.value == 'E-mail') this.value='';" onblur="if(this.value == '') this.value='E-mail';"></p>
<? echo $statusde;?>
<p><input type="submit" class="fa-align-left" value="Enviar"></p>
<p><input type="hidden" name="send" value="true"></p>
</ul>
</form>
E O PHP ESTÁ ASSIM!!!
<?php
if(@$_POST['send'] == "true"){ // Se o form nao for preenchido ele nao ira enviar o email>>>
// Aqui voce coloca o E-MAIL para onde sera enviado o EMAIL>>>>>>>>>
$destinatario = 'meuemail@meuemail.com.br';
//$destino ='meuemail@meuemail.com.br';
$nome = $_POST['nome'];
$telefone = $_POST['telefone'];
$email = $_POST['email'];
$headers = "Content-Type: text/html; charset=iso-8859-1\n";
$headers .= "From: $destinatario - Baixou Cartálogo <meuemail@meuemail.com.br>\r\n"; // colocar o email da plocad.
$fonte = "<font size=\"-1\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
$msg = "$fonte Você recebeu um e-mail de: $email <br>";
$msg .= "<br> Nome: $nome <br> ";
$msg .= "<br> Telefone: $telefone ";
$msg .= "<br> E-mail: $email <br>";
$envia = mail("$destinatario", "$msg", "$headers");
if(@$_POST['send'] == "true"){
if($envia){
$statusde="<font color='#FF0000'> Aguarde o download iniciar!</font>";
}else{
$statusde="<font color='#FF0000'>Erro ao enviar, favor enviar novamente.</font>";
}
}
if($envia){
$statusde="<font color='#FF0000'>Aguarde o download iniciar!</font>";
}else{
$statusde="<font color='#FF0000'>Erro ao enviar, favor enviar novamente.</font>";
}
}
if($envia) {
echo "Agradecemos seu contato, Ok para iniciar o Download!";
echo "<script>alert(\"Clique em OK para iniciar o Download!\")</script>";
echo "<script>window.location = \"1.pdf\"</script>";
}
else{/*seu ouve algum erro...*/
echo "<p><b>$nome</b><br />Ouve um erro no envio, desculpe-nos pelo transtorno!!!</p>";
}
?>
-
Por jrdesign
Bom dia, sou novo em php, abaixo está a forma que estou tentando fazer, porém o email não está chegando. Não tenho acesso ao servidor para fazer os testes.
Após preencher o formulário com nome. e-mail e telefone... aparece para fazer o download e clicando em ok libera o dowload, mas não chega o e-mail com os dados preenchidos.
Hospedagem Locaweb.
Obrigado a todos.
<?php
if(@$_POST['send'] == "true"){ // Se o form nao for preenchido ele nao ira enviar o email>>>
// Aqui voce coloca o E-MAIL para onde sera enviado o EMAIL>>>>>>>>>
$destinatario = 'meuemail@meuemail.com.br';
//$destino ='meuemail@meuemail.com.br';
$nome = $_POST['nome'];
$telefone = $_POST['telefone'];
$email = $_POST['email'];
$headers = "Content-Type: text/html; charset=iso-8859-1\n";
$headers .= "From: $destinatario - Baixou Cartálogo <meuemail@meuemail.com.br>\r\n"; // colocar o email da plocad.
$fonte = "<font size=\"-1\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
$msg = "$fonte Você recebeu um e-mail de: $email <br>";
$msg .= "<br> Nome: $nome <br> ";
$msg .= "<br> Telefone: $telefone ";
$msg .= "<br> E-mail: $email <br>";
$envia = mail("$destinatario", "$msg", "$headers");
if(@$_POST['send'] == "true"){
if($envia){
$statusde="<font color='#FF0000'> Aguarde o download iniciar!</font>";
}else{
$statusde="<font color='#FF0000'>Erro ao enviar, favor enviar novamente.</font>";
}
}
if($envia){
$statusde="<font color='#FF0000'>Aguarde o download iniciar!</font>";
}else{
$statusde="<font color='#FF0000'>Erro ao enviar, favor enviar novamente.</font>";
}
}
if($envia) {
echo "Agradecemos seu contato, Ok para iniciar o Download!";
echo "<script>alert(\"Clique em OK para iniciar o Download!\")</script>";
echo "<script>window.location = \"1.pdf\"</script>";
}
else{/*seu ouve algum erro...*/
echo "<p><b>$nome</b><br />Ouve um erro no envio, desculpe-nos pelo transtorno!!!</p>";
}
?>
-
Por geoleandro
O botão voltar funciona, mas ele adiciona uma questão na variável "numQ".
Onde está o erro no código abaixo:
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> .imgbox { float: left; text-align: center; width: 150px; border: 1px solid #ddd; margin: 4px; padding: 5px; } #mylabel { text-align: left; } </style> <body onload="loadquestion()"> <p id="numQ"> <p id="mylabel" name="questao">Questões</p><br> <div class="imgbox" id="imgbox1"><br> <input type="image" src=" " width =auto height= 80px id="btn0" value="option0" name="opt0" onclick="checkans(1)"><br><br> </div> <div class="imgbox" id="imgbox2"><br> <input type="image" src=" " width =auto height= 80px id="btn1" value="option1" name="opt1" onclick="checkans(2)"><br><br> </div> <br><br><br><br><br><br><br><br><br> <div class="imgbox" id="imgbox3"><br> <input type="image" src=" " width =auto height= 80px id="btn2" value="option2" name="opt2" onclick="checkans(3)"><br><br> </div> <div class="imgbox" id="imgbox4"><br> <input type="image" src=" " width =auto height= 80px id="btn3" value="option3" name="opt3" onclick="checkans(4)"><br><br> </div> <br><br><br><br><br><br> <br><br><br><br> <input type="button" id="next" value="Próximo" name="nxtbtn" onclick="changequestion()"><br><br> <input type="button" id="back" value="voltar" name="bkbtn" onclick="backQ()"><br><br> <p id="erro"> <p id="pontos"> <p id="questAtual"> <script type="text/javascript"> i=0; var pontos = 0; var numQ = 1; myqs=[["Clique na foto 3 ?","img3.gif", "img2.gif","img1.gif","img1a.gif","3"], ["Clique na foto 2 ?","icone.png","icone2.png","certo.png","certo.png","2"], ["Clique na foto 4","icone.png","errado.png","certo.png","certo.png","4"] ]; function loadquestion() { document.getElementById("mylabel").innerHTML= myqs[i][0]; document.getElementById("btn0").src= myqs[i][1]; document.getElementById("btn1").src= myqs[i][2]; document.getElementById("btn2").src= myqs[i][3]; document.getElementById("btn3").src= myqs[i][4]; document.getElementById ("numQ").innerHTML = "Questão " + numQ + " de " + myqs.length; document.getElementById("next").value = "Próximo"; document.getElementById("next").style.backgroundColor = "lightgray"; numQ++; document.getElementById("imgbox1").style.backgroundColor = "white"; document.getElementById("imgbox2").style.backgroundColor = "white"; document.getElementById("imgbox3").style.backgroundColor = "white"; document.getElementById("imgbox4").style.backgroundColor = "white"; document.getElementById("erro").innerHTML = ""; document.getElementById("erro").style.color = ""; } function changequestion(){ i=i+1; loadquestion(); } function backQ(){ loadquestion(); i=i-1 } function checkans(a){ respostas =parseInt(myqs[i][5]); if(respostas==a && respostas==3){ pontos++; document.getElementById ("pontos").innerHTML = "Você acertou " + pontos ; document.getElementById("imgbox3").style.backgroundColor = "#99ff99"; } else if(respostas==a && respostas==2){ pontos++; document.getElementById ("pontos").innerHTML = "Você acertou " + pontos ; document.getElementById("imgbox2").style.backgroundColor = "#99ff99"; } else if(respostas==a && respostas==4){ pontos++; document.getElementById ("pontos").innerHTML = "Você acertou " + pontos ; document.getElementById("imgbox4").style.backgroundColor = "#99ff99"; } else { document.getElementById("erro").innerHTML = "Incorreta"; document.getElementById("erro").style.color = "red"; } } </script> </head> </body> </html>
-
Por Marcelbs
Olá pessoal, td bem?
Gostaria de saber se alguém faz idéia por que tem hora que o e-mail enviado via formulário chega e hora não chega. No Gmail e no Bol está tudo funcionando, porém é no e-mail Locaweb é que está acontecendo a confusão. Percebi que quando põe acento no campo do assunto, em um dos meus e-mails Locaweb, o e-mail vai pra spam. Em outro e-mail Locaweb simplesmente não chega em lugar nenhum. Todavia em todos os casos o formulário me avisa que foi enviado corretamente.
Vou postar os códigos que programei:
função javascript que valida o formulário:
function validacaoContato(){ /* console.log('valida formulario'); */ $("#formulario").validate({ rules:{ nome: {required: true}, email: {required: true, email: true}, assunto: {required: true}, mensagem:{required: true} }, messages:{ nome: {required: "Favor informar o seu nome"}, email: {required: "Favor informar o seu e-mail", email:"favor preencher um e-mail válido"}, assunto: {required: "Favor preencher com um assunto"}, mensagem:{required: "Favor preencher com uma mensagem"}, }, errorElement:"div", wrapper:"div", errorPlacement: function(error, element) { error.appendTo(element.closest('div')); error.css({ "color":"red", "font-size":"14px", "position":"absolute", "top":element.closest("div").find(".contato_form_field").height()+50+"px", "text-align":"right" }); }, submitHandler: function(form) { var variaveis = $(form).serialize(); $.ajax({ url: "php/js_php/envia_email.php", type: "POST", data: variaveis+'&destinatario='+representante_email, dataType:"json", success: function(resposta_do_arquivo_php){ if (resposta_do_arquivo_php.sucesso == 1) { $("#formulario").prepend('<div id="form_sobrepoe" style="position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;background:none;"></div>'); $(".resposta").html(""); $(".resposta").html("e-mail enviado com sucesso").appendTo("#form_sobrepoe").css({'color':'green','margin':'5px 0 10px 0','display':'block','position':'absolute','bottom':'0px'}); $("#nome").val(""); $("#email").val(""); $("#assunto").val(""); $("#mensagem").val(""); } else { $(".resposta").html(""); $(".resposta").html("ops, ocorreu um erro, tente novamente mais tarde").css({'color':'red','margin':'5px 0 10px 0','display':'block'}); $("#nome").val(""); $("#email").val(""); $("#assunto").val(""); $("#mensagem").val(""); } }, error: function(a,b,c){ /* console.log(a,b,c); */ $(".resposta").html(""); $(".resposta").html("Ops, ocorreu um erro, tente novamente mais tarde").css({'color':'red','margin':'5px 0 10px 0','display':'block'}); } }); } }) } arquivo php que recebe as variáveis:
<?php require_once "../classes/EnviaEmail.class.php"; $nome = $_POST['nome']; $email = $_POST['email']; $assunto = $_POST['assunto']; $mensagem = $_POST['mensagem']; $destinatario = $_POST['destinatario']; $texto = '<html> <head> </head> <body> contato: <br/><br/> De: '.$nome.' <br/><br/> E-mail: '.$email.' <br/><br/> Assunto: '.$assunto.' <br/><br/> Mensagem: '.$mensagem.'<br/><br/> </body> </html>'; $email_c = new EnviaEmail($email,$assunto,$destinatario,$texto,1); $email_c->enviaEmail(); ?> e a classe que envia o e-mail:
<?php class EnviaEmail { private $_emailsender,$_email_remetente,$_destinatario,$_assunto,$_headers,$_mensagem,$_quebra_linha,$_array_resposta,$_r; public function __construct($email_p,$assunto_p,$destinatario_p,$mensagem_p,$r){ $this->_email_remetente = $email_p; $this->_assunto = $assunto_p; $this->_destinatario = $destinatario_p; $this->_mensagem = $mensagem_p; $this->_r = $r; } private function configuraVars(){ $this->_emailsender = "emailautomatico@" . str_replace('www.','',$_SERVER['HTTP_HOST']); if(PHP_OS == "Linux"){ $this->_quebra_linha = "\n"; //Se for Linux } elseif(PHP_OS == "WINNT"){ $this->_quebra_linha = "\r\n"; // Se for Windows } else { $this->_array_resposta['sucesso'] = 0; $this->_array_resposta['mensagem'] = 'erro'; exit($this->_array_resposta); } } private function montaHeaders(){ $headers = "MIME-Version: 1.1" .$this->_quebra_linha; $headers .= "Content-type: text/html; charset=utf-8" .$this->_quebra_linha; $headers .= "From: " . $this->_emailsender.$this->_quebra_linha; if(strlen($this->_destinatario) > 0) $headers .= "Cc: ".$this->_destinatario.$this->_quebra_linha; if(strlen($this->_destinatario) > 0) $headers .= "Bcc: ".$this->_destinatario.$this->_quebra_linha; $headers .= "Reply-To: " . $this->_email_remetente . $this->_quebra_linha; return $headers; } public function enviaEmail(){ /* header('Content-Type: text/html; charset=utf-8');*/ $this->configuraVars(); $this->_headers = $this->montaHeaders(); if(mail($this->_destinatario, $this->_assunto, $this->_mensagem, $this->_headers, "-r". $this->_emailsender)){ $this->_array_resposta['sucesso'] = 1; } else { $this->_array_resposta['sucesso'] = 0; }; if($this->_r == 1){ echo json_encode($this->_array_resposta); } } } ?> obrigado a todos
-
Por geoleandro
Boa tarde pessoal
Eu gostaria de alterar o background das alternativas abaixo para a cor verde, senão para vermelho. Porém só consigo fazer para o formulário inteiro.
Estou travado nessa parte, qualquer ajuda seria bem-vinda.
Obrigado
<!DOCTYPE html>
<html>
<body>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div style='line-height: 25px;font-family: arial;'
<p align="justify">
<br/>
Responda as questões a seguir:
<br/>
<form id = "quiz" name = "quiz">
<p>Qual é a capital do Peru?</p>
<input id = "textbox" type = "text" name = "q1">
<br>
<p>Qual é a capital do Equador?</p>
<input type = "radio" id = "multipla" name = "q2" value = "Quito"> Quito<br>
<input type = "radio" id = "multipla" name = "q2" value = "Quieto"> Quieto<br>
<p>Qual é a capital da Argentina?</p>
<input type = "radio" id = "multipla" name = "q3" value = "Buenas tardes"> Buenas tardes<br>
<input type = "radio" id = "multipla" name = "q3" value = "Buenos Aires"> Buenos Aires<br>
<br><br>
<input id = "button" type = "button" value = "Conferir" onclick = "checar()">
</form>
</div>
<p id = "numeroCorreto"></p>
<p id = "mensagem"></p>
<img id = "imagem" style= width="300" height="150">
<p id = "cor"></p>
</div>
<script>
function checar() {
var q1 = document.quiz.q1.value;
var q2 = document.quiz.q2.value;
var q3 = document.quiz.q3.value;
var corretas = 0;
var cor = ["#006400", "#006400","#FF0000" ];
if (q1 == "Lima") {
corretas++;
}
if (q2 == "Quito") {
corretas++;
}
if (q3 == "Buenos Aires") {
corretas++;
}
var mensagem = ["Parabéns!", "Foi bom!", "Melhor tentar novamente!"];
var imagem = ["img1.gif", "img2.gif", "img3.gif"];
var pontos;
if (corretas < 1) {
pontos = 2;
}
if (corretas > 0 && corretas < 3) {
pontos = 1;
}
if (corretas > 2) {
pontos = 0;
}
document.getElementById ("numeroCorreto").innerHTML = "Você acertou " + corretas + " de 3 perguntas.";
document.getElementById ("mensagem").innerHTML = mensagem[pontos];
document.getElementById ("imagem").src = imagem[pontos];
document.getElementById("quiz").style.backgroundColor = cor [pontos];
}
</script>
</div>
</p>
</div>
</body>
</html>
-