I am having a problem when entering same values in the same column. The program should execute an alert when the values entered are the same as the existing record in mysql. Party and Position are the fields. E.g. The program should not accept 'President' in the same 'party' when there's already a record having the same values.
Please help:
Here's the code I write:
if($_POST['party'] == $row['Party']){
if($_REQUEST['position'] == 'President'){
echo "<script>
alert('There is already a President or Vice President for the Partylist');
window.location.href = 'add_candidate.php';
</script>";
session_destroy();
}
else if($_REQUEST['position'] == "Vice President") {
echo "<script>
alert('There is already a President or Vice President for the Partylist');
window.location.href = 'add_candidate.php';
</script>";
session_destroy();
}
else {
//ito yung nagdadagdag ng data sa table
mysqli_query($con,"INSERT INTO tbl_candidate VALUES('$idNumber', '$fname','$mname', '$lname', '$year', '$course', '$position', '$party', '$picture','0')");
header('Location: list_candidate.php');
}
}
else {
//ito yung nagdadagdag ng data sa table
mysqli_query($con,"INSERT INTO tbl_candidate VALUES('$idNumber', '$fname','$mname', '$lname', '$year', '$course', '$position', '$party', '$picture','0')");
header('Location: list_candidate.php');
}
}