I have this notification page (page before going to register page) this page check data from database, if false / true will show message under textbox, but its only to show that message not block process input. This one my notification page (show true message if from check.php no conflic):
<head>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/settings.js" type="text/javascript"></script>
<SCRIPT type="text/javascript">
pic1 = new Image(16, 16);
pic1.src = "img/loader.gif";
//untuk nim
$(document).ready(function(){
$("#cekintern").change(function() {
var nomor = $("#cekintern").val();
if(nomor.length >= 8)
{
$("#status2").html('<img src="img/loader.gif" align="absmiddle"> Checking availability...');
$.ajax({
type: "POST",
url: "check.php",
data: "cekintern="+ nomor,
success: function(msg){
$("#status2").ajaxComplete(function(event, request, settings){
if(msg == 'OK')
{
$("#cekintern").removeClass('object_error'); // if necessary
$("#cekintern").addClass("object_ok");
$(this).html(' <img src="img/accepted.png" align="absmiddle"> <font color="Green"> Available </font> ');
}
else
{
$("#cekintern").removeClass('object_ok'); // if necessary
$("#cekintern").addClass("object_error");
$(this).html(msg);
}
});
}
});
}
else
{
$("#status2").html(' <img src="img/decline.jpg" align="absmiddle"> <font color="red">Maaf NIM anda salah.</font>');
$("#cekintern").removeClass('object_ok'); // if necessary
$("#cekintern").addClass("object_error");
alert('Maaf NIM salah!!'); window.location.href='?get=2';
}
});
});
//-->
</SCRIPT>
</head>
<body><br />
<form name="form1" method="post" action="register.php">
<center>
<em>Input <strong>NIM</strong></em><br />
<input name="cekintern" type="text" id="cekintern" size="15" maxlength="9" placeholder="Input NIM Here"/><div id="status2"></div><br />
<input type="submit" value="Confirm" />
<input type="button" name="button" id="button" value="Cancel" onClick="window.location='index.php'"/></center>
</form>
and this one check.php to check from database and show message error if has conflic:
<?php if(isSet($_POST['cekintern']))
{
$nimintern = $_POST['cekintern'];
$sql_check = mysql_query("SELECT * FROM {$prefix}intern WHERE nim='$nimintern'");
if(mysql_num_rows($sql_check))
{
$nimintern = $_POST['cekintern'];
$sql_check2 = mysql_query("SELECT * FROM {$prefix}pengguna WHERE nim_pengguna='$nimintern'");
if(mysql_num_rows($sql_check2))
{
echo ' <img src="img/decline.jpg" align="absmiddle"> <font color="red">Maaf NIM <STRONG>'.$nim.'</STRONG> nim anda sudah terdaftar.</font>';
return false;
}
else
{
echo 'OK';
}}
else
{
echo ' <img src="img/decline.jpg" align="absmiddle"> <font color="red">Maaf NIM <STRONG>'.$nim.'</STRONG> tidak ada dalam daftar mahasiswa.</font>';
return false;
}}
?>
all message is works, but im confuse what should i write to make notification.php (javascrit) & check.php (php) cancel input if the message is has conflic.