Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
O erro após o envio eh esse:
Erro! Digite o codigo corretamente!
Tente Novamente'; session_destroy(); } ?>
Agora o html
contato.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lojão dos Condomínios</title>
</head>
<body onLoad="antespan()">
<div id="retorno">
<form name="form1" method="post" action="">
<table width="456" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="90" align="right">Nome:</td>
<td colspan="2" align="left"><input name="nome" type="text" id="nome" size="50"></td>
</tr>
<tr>
<td align="right">Assunto:</td>
<td colspan="2" align="left"><input type="text" name="assunto" id="assunto"></td>
</tr>
<tr>
<td align="right">Email:</td>
<td colspan="2" align="left"><input name="email" type="text" id="email" size="50"></td>
</tr>
<tr>
<td align="right">Menssagem:</td>
<td colspan="2" align="left"><textarea name="menssagem" cols="50" rows="5" id="menssagem"></textarea></td>
</tr>
<tr>
<td align="right">Ante-Span:</td>
<td width="30" align="left"><input name="cod" type="text" id="cod" size="5"></td>
<td width="271" align="left"><span id="antespan"></span></td>
</tr>
<tr>
<td></td>
<td colspan="2" align="left"><input onClick="enviar();" type="button" name="bt" id="bt" value="Enviar"></td>
</tr>
</table>
</form>
</div>
<noscript>
Erro! Abilite o javascript em seu Navegador!
</noscript>
</body>
</html>
<script src="scripts/ajax.js"></script>
<script src="scripts/form.js"></script>
mail.php
<?
session_start();
$assunto = $_POST['assunto'];
$cod = $_POST['cv'];
$mens = "Nome:".$_POST['nome']."\n".$_POST['mens'];
$email = $_POST['email'];
if($_SESSION['cv']==$cod){
mail('robin-4169@hotmail.com',$assunto,$mens,"From: ".$email);
echo "Sua Mensagem foi Enviada com sucesso!";
session_destroy();echo '<b>Erro!</b> Digite o codigo corretamente!<br><a onclick="window.location.reload();" href="contato.html">Tente Novamente</a>';
session_destroy();
}
?>
antespan.php
<?php
header("Content-type: image/png");
session_start();
$_SESSION['cv'] = rand(10000,90000);
$im = @imagecreate(90, 18) or die("Erro indefinido!");
//$im = ImageCreateFromPNG('bg'.rand(1,3).'.png');
$background_color = imagecolorallocate($im, 200, 200, 200);
$text_color = imagecolorallocate($im, 300, 0, 0);
imagestring($im, 5, 20, 2,$_SESSION['cv'], $text_color);
imagepng($im);
imagedestroy($im);
?>
Codigo ajax.js
//Ajax funcional criado por Leandro Cunha!
// Contato leandrocunha01@gmail.com
// Todos direitos reservados.
var xmlhttp = null;
function httprequest() {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined' ) {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false ;
}
}
if (xmlhttp) {
xmlhttp.onreadystatechange = retorno;
xmlhttp.open(metodo, url,true);
if(metodo=='POST'){
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
xmlhttp.send(dados);
}
}
function retorno () {
//obj_status.innerHTML = 'Analisando pedido...';
if ( xmlhttp.readyState == 4) {
if ( xmlhttp.status == 200) {
obj_retorno.innerHTML = xmlhttp.responseText;
} else {
// obj_status.innerHTML = xmlhttp.statusText;
alert('Erro: '+ xmlhttp.statusText);
}
}
}
ultimo form.js
function enviar(){
url = "mail.php";
nome = document.getElementById("nome").value;
email = document.getElementById("email").value;
mens = document.getElementById("menssagem").value;
assunto = document.getElementById("assunto").value;
cod = document.getElementById("cod").value;
dados = "nome="+nome+"&email="+email+"&mens="+mens+"&assunto="+assunto+"&cv="+cod;
metodo = 'POST';
obj_retorno = document.getElementById("retorno");
if(nome==false||email==false||mens==false||cod==false){
alert("Preencha todos os Campos");
} else {
document.getElementById('bt').value ="Enviando...";
document.getElementById('bt').disabled =true;
httprequest();
}
}
function antespan(){
url = "ts.php";
document.getElementById('bt').disabled =false;
dados = 'vs';
metodo = 'GET';
obj_retorno = document.getElementById("antespan");
httprequest();
}
function click() {
if (event.button==2||event.button==3) {
oncontextmenu='return false';
}
}
document.onmousedown=click
document.oncontextmenu = new Function("return false;")
Isso eh tudo q eu tnhu aki e o erro eh q diz q o codigo esta errado, ele nao valida o codigo nao sei porq :ermm:
Agradeço se puderem ajudar!
Obrigado :thumbsup:
Carregando comentários...