i have a problem with check the data
the form is arrray..
In this coding, if data was found in database,it show the alert pop-up window
but the data still inserted in the database..
if i add the exit(); fuction after the pop-up coding..the data which not found in database, is not insert into database..
Please help me to fix the coding..
require_once('Connections/repi.php');
// *** Redirect if username exists
$MM_flag="Hantar";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="data_ada_kelas_subjek.php";
$id = $_POST['id'];
$jenis = $_POST['jenis'];
$tahun = $_POST['tahun'];
if(is_array($_POST['kod'])){
foreach( $_POST['kod'] as $kod ){
$LoginRS__query = "SELECT ID_STUD, SEM, TAHUN, SUBJECT_KOD FROM result WHERE (ID_STUD='" . $id . "' AND SEM='" . $jenis . "') AND (TAHUN='" . $tahun . "' AND SUBJECT_KOD='" . $kod . "') ";
mysql_select_db($database_repi, $repi);
$LoginRS=mysql_query($LoginRS__query, $repi) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
echo "<script language='Javascript'>
alert('Markah Untuk Subjek Kod ".$kod." Telah Ada Dalam Rekod');
</script>";
}
}
}
}