Ciao a tutti, ho un piccolo form per registrazione a newsletter, sto cercando di far verificare prima dell'invio del form se la mail è già presente tra i registrati usando ajax.
ho la pagina del form che è iscrivimi.php con questo codice:
<head>
<meta -equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Iscrizoine newsletter</title>
<script type="text/javascript" src="include/livevalidation.js"></script>
<script src="include/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
function check(){
var str=$("#email").attr('value');
$.ajax ({
type:'GET',
url:'ajax_02.php?stringa='+str,
dataType:'text',
success:function (risposta){
$('#errore').html(risposta);
if(risposta==''){
document.getElementById('bottone').disabled=false;
}else{
document.getElementById('bottone').disabled='disab led';
}
}
})
}
</script>
</head>
<body>
<form name="info" action="iscrivimi.php" method="post">
<fieldset>
<legend>Iscrivimi</legend>
<label for="email">Email</label>
<input type="text" id="email" name="email" onblur="check();" />
<span id="errore"></span>
...
<input type="submit" id="bottone" disabled="disabled" />
</form>
Poi ho la pag ajax_02.php dove gestisco il controllo:
<?
include('include/config.inc.php');
$str=$_GET['stringa'];
$sql='SELECT count(mem_id) FROM membri WHERE mem_email="'.$str.'"';
$result=mysql_query($sql,$miaconn) or die($sql);
$row=mysql_fetch_row($result);
if($row[0]>0){echo 'email presente';}
?>
Il problema è che non mi fa alcun controllo e il bottone del form rimane sempre disabilitato. Qualcuno può aiutarmi per favore? Grazie ciao Simone