I want to submit data of my student registration form to the database. If an admission number already exists, a message should be displayed like this.
"Admission number2012/1..This student has been already entered to the system."
I have created the below coding which fulfill the above task. But i want slight modification, rather than displaying the message in a seperate field after entering all the fields i want the message to display soon after entering the "Admission Number" in my form.
Can anyone give me the relevant AJAX code to solve this issue?
newStudentRegistrationFormValidation.php
<?php
$admission_no=$_POST['admission_no'];
$admission_date=$_POST['admission_date'];
$full_name=$_POST['full_name'];
$name_with_initial=$_POST['name_with_initial'];
$date_of_birth=$_POST['date_of_birth'];
$religion=$_POST['religion'];
//$gender=$_POST['gender'];
$address=$_POST['address'];
$telephone=$_POST['telephone'];
$grade_on_admission=$_POST['grade_on_admission'];
$grade_ID=$_POST['grade_ID'];
$stream_ID=isset($_POST['stream_ID']);
$class_ID=$_POST['class_ID'];
$student_house=$_POST['student_house'];
$password=$_POST['password'];
$description_about_st=$_POST['description_about_st'];
$payment=$_POST["payment"];
$currentdate=getdate(time());
$year=$currentdate["year"];
//admission number validation
$con=mysql_connect("localhost","root","");
mysql_select_db("student_management",$con);
$query="SELECT admission_no FROM student_info Where student_info.admission_no='$admission_no'";
$result=mysql_query($query) ;
$num_rows = mysql_num_rows($result);
echo $num_rows;
if($num_rows >= 0)
{
header("location:student registrationDatabase.php?admission_no=".urlencode($admission_no)."&year=".urlencode($year)."&admission_date=".urlencode($admission_date)."&full_name=".urlencode($full_name)."&name_with_initial=".urlencode($name_with_initial)."&date_of_birth=".urlencode($date_of_birth)."&religion=".urlencode($religion)."&address=".urlencode($address)."&telephone=".urlencode($telephone)."&grade_on_admission=".urlencode($grade_on_admission)."&grade_ID=".urlencode($grade_ID)."&stream_ID=".urlencode($stream_ID)."&class_ID=".urlencode($class_ID)."&student_house=".urlencode($student_house)."&password=".urlencode($password)."&description_about_st=".urlencode($description_about_st)."&payment=".urlencode($payment));
exit();
}else{
?>
<body>
<?php
echo "Admission number".$admission_no." .This student has been already entered to the system ."."<BR>"."<BR>"."<BR>";
echo "<a href='newStudentRegistrationForm.php'>GO to manage student details page</a> ";
exit();
}?>
</body>
</html>Inline Code Example Here
This is how my form looks like.
<form name="form1" method="post" action="newStudentRegistrationFormvalidation.php">
<table>
<tr>
<td width="20"> </td>
<td colspan="4"><h3>
<label><strong>Add Student Information</strong></label>
<strong> </strong></h3></td>
<td width="1"> </td>
<td width="1"> </td>
<td width="6"> </td>
</tr>
<tr>
<td> </td>
<td width="261"><label>Admission Number </label> </td>
<td colspan="2">
<input type="text" name="admission_no" id="textfield" /></td>
<td width="127"> </td>
<td> </td>
<td> </td>
</tr>
--------
-------
</table>
</form>