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();
}

}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.