Jump to content

Regarding An Admission Number Validation


heshan

Recommended Posts

I want something like this to be done as a validation.

 

In my form there 3 fields. Admission Number, Year and Term.

 

If an user enters an admission number which is not exist in my database table a proper validation should display as "Invalid admission number". How this can be done?

 

I have already validated marks added.

 

<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("student_management",$con);
$admission_no=$_POST["admission_no"];
$term=$_POST["term"];
$year=$_POST["year"];
//validate

$query="SELECT COUNT(*) FROM mark INNER JOIN exam ON mark.exam_id=exam.exam_id
    WHERE mark.admission_no='$admission_no' AND exam.exam_name='$term' AND exam.year='$year'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
if($row[0]==0)
 {
header("location:addStudentMarkForm.php?admission_no=".$admission_no."&term=".$term."&year=".$year);
exit();

}else{

?>
<?php
echo "For this admission number ".$admission_no." tream".$term." marks has been already Added.";
echo "<BR><BR><BR>";
echo "<a href='addStudentMark.php'>Go to Add student mark page.</a>";
exit();
}

}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.