Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
olá, montei uma página para enviar recados e para evitar spam coloquei um javascript acoplado ao formlário que bloqueia atraves de cookie o tempo limite para envio desses recados e tambem não permite campos vazios, so que não está aontecendo isso, á como se não tivesse o java script vou postar o código completo abaixo:
<link href="style/stylepaginas.css" rel="stylesheet" type="text/css">
<?php
if($_POST['muralrecados']){
$nome = $_POST['nome'];
$email = $_POST['email'];
$cidade = $_POST['cidade'];
$estado = $_POST['estado'];
$recado = $_POST['recado'];
$data = date('d/m/Y - H:i:s');
$ip = $_SERVER['REMOTE_ADDR'];
mysql_query("INSERT INTO mural_recados (nome, email, cidade, estado, recado, data, ip) VALUES ('$nome', '$email','$cidade','$estado','$recado','$data','$ip')");
echo "<script> window.alert('Seu Recado Foi Enviado Com Sucesso!'); location.href='?sess=mural_de_recados';</script>";
}
?>
<style type="text/css">
<!--
}
textarea {
width: 300px;
height: 200px;
}
#progreso {
background: url(imagens/textarea.png) no-repeat;
background-position: -300px 0px;
width: 300px;
height: 14px;
text-align: center;
color: #000000;
font-size: 8pt;
font-family: Arial;
text-transform: uppercase;
}
.tbl_caixa_amarelo {
background-color: #FFCF00;
border: #000000 outset 1px;
}
-->
</style>
<script type="text/javascript">
var max=250;
var ancho=300;
function progreso_tecla(obj) {
var progreso = document.getElementById("progreso");
if (obj.value.length < max) {
progreso.style.backgroundColor = "#F0F0F0";
progreso.style.backgroundImage = "url(imagens/textarea.png)";
progreso.style.color = "#000000";
var pos = ancho-parseInt((ancho*parseInt(obj.value.length))/250);
progreso.style.backgroundPosition = "-"+pos+"px 0px";
} else {
progreso.style.backgroundColor = "#CC0000";
progreso.style.backgroundImage = "url()";
progreso.style.color = "#FFFFFF";
}
progreso.innerHTML = "("+obj.value.length+" / "+max+")";
}
//limitatempo
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
history.go(0);
}
}
function fixDate(date) {
var base = new Date(0);
var skew = base.getTime();
if (skew > 0) date.setTime(date.getTime() - skew);
}
function valida_campo()if(getCookie('radiolol')) {
alert('Voce só poderá enviar outro recado depois de 1hora');
return false;
}
var nome = document.form.nome.value
if ($nome=="")
{
alert("Por favor informe seu nome!");
document.form.nome.focus()
return false
}
var email = document.form.email.value
if ($email=="")
{
alert("Por favor informe seu email!");
document.form.email.focus()
return false
}
var cidade = document.form.cidade.value
if ($cidade=="")
{
alert("Por favor informe sua cidade!");
document.form.cidade.focus()
return false
}
var cidade = document.form.recado.value
if ($recado=="")
{
alert("Por favor preencha seu recado!");
document.form.recado.focus()
return false
}
if(getCookie('radiolol')) {
alert('Você só poderá enviar outro recado depois de 1hora');
return false;
}
data = new Date();
fixDate(data);
data.setTime(data.getTime() + 3600 * 1000);
setCookie('radiolol', 'ok', data);
}
</script>
<table width="99%" border="0">
<tr>
<td width="1%"> </td>
<td width="99%"><table width="99%" border="0">
<tr>
<td width="99%"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th height="30" colspan="3" background="images/bases/base_padrao.png" class="titulos" scope="col">Enviar Recado</th>
</tr>
<tr>
<th colspan="3" scope="col"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="tbl_fundocinza">
<tr>
<th bgcolor="#F0F0F0" scope="col"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="2" class="tbl_fundocinza">
<tr>
<th bgcolor="#F0F0F0" scope="col"><form name="muralrecados" method="post" action="" onSubmit="return valida_campo()">
<br>
<table width="101%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="6%" height="32" class="textosblack" scope="col"><div align="left"><strong>Nome:</strong></div></td>
<td width="26%" scope="col"><div align="left">
<input name="nome" type="text" class="tbl_caixadetexto" id="$nome" size="30" />
</div></td>
<td width="5%" class="textosblack" scope="col"><div align="left"><strong>Email:</strong></div></td>
<td width="63%" scope="col"><div align="left">
<input name="email" type="text" class="tbl_caixadetexto" id="$email" />
</div></td>
</tr>
<tr>
<td class="textosblack"><div align="left"><strong>Estado:</strong></div></td>
<td><div align="left"><span class="style4 style4" style="font-family: Tahoma">
<select name="estado" class="tbl_caixadetexto" id="$estado" style="width:100px; height:18px; margin-left:4px; font-family:arial; font-size:10px; border:1px solid #666666;" onFocus="if (this.value == 'BA') {this.value = ''}" onBlur="if (this.value == '') {this.value = 'BA'}">
<option value="AL" >AL</option>
<option value="AP" >AP</option>
<option value="AM" >AM</option>
<option value="BA" >BA</option>
<option value="CE" >CE</option>
<option value="DF" >DF</option>
<option value="ES" >ES</option>
<option value="GO" >GO</option>
<option value="MA" >MA</option>
<option value="MG" >MG</option>
<option value="MT" >MT</option>
<option value="MS" >MS</option>
<option value="PA" >PA</option>
<option value="PB" >PB</option>
<option value="PR" >PR</option>
<option value="PE" >PE</option>
<option value="RJ" >RJ</option>
<option value="RN" >RN</option>
<option value="RS" >RS</option>
<option value="RO" >RO</option>
<option value="RR" >RR</option>
<option value="SC" >SC</option>
<option value="SP" >SP</option>
<option value="SE" >SE</option>
<option value="TO" >TO</option>
</select>
</span></div></td>
<td class="textosblack"><div align="left"><strong>Cidade:</strong></div></td>
<td><div align="left">
<input name="cidade" type="text" class="tbl_caixadetexto" id="$cidade" />
</div></td>
</tr>
<tr>
<td colspan="4"><div align="center" class="textosblack"><strong>Recado:</strong> (250 dígitos máx.) tags permitidas: <br> <b></div></td>
</tr>
<tr>
<td colspan="4"><div align="center">
<textarea name="recado" onKeyUp="progreso_tecla(this)" cols="40" class="tbl_caixadetexto" id="$recado" style="width:98%; height:40px; margin-left:4px; border:1px solid #666666;">Somente texto (250 digitos max.)</textarea>
<br>
</div></td>
</tr>
<tr>
<td colspan="4" align="center"><div align="center" id="progreso">
<div align="center">(0 / 250 )</div>
</div></td>
</tr>
<tr>
<td colspan="4" align="center"><input name="muralrecados" type="submit" class="tbl_caixa_amarelo" value="Adicionar">
<input name="limpar" type="reset" class="tbl_caixa_amarelo" id="limpar" value="Limpar"></td>
</tr>
</table>
</form></th>
</tr>
</table></th>
</tr>
</table></th>
</tr>
<tr>
<td width="10" scope="col"><img src="images/bases/esquerda_final.png" width="10" height="10" /></td>
<td width="956" height="10" background="images/bases/centro_final.png" scope="col"></td>
<td width="10" scope="col"><img src="images/bases/direita_final.png" width="10" height="10" /></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
minhas dúvidas ficam entre as linhas:
65 a 151
e 166
fico no aguardo e agradeço desde já!
Carregando comentários...