Hi all,
I have small problem regarding my student registration form. When i enter data and submit always below message is displayed irrespective of whether the admission_id is exist or not.
"Admission numberThis student has been already entered to the system"
newStudentRegistrationForm.php
<form name="form1" method="post" action="newStudentRegistrationFormvalidation.php">
<?PHP
$con=mysql_connect("localhost","root","");
mysql_select_db("student_management",$con);
?>
<table width="850" border="1" align="center">
<tr>
<td colspan="2"><table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="25%"><img src="IMAGE/logo.png" width="200" height="200" /></td>
<td width="75%" align="center" valign="middle"><div align="center">
<blockquote>
<p><img src="../../IMAGE/banner.jpg" width="491" height="88" /></p>
</blockquote>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td width="170"> </td>
<td width="664"><table width="600" border="0">
<tr>
<td width="124"> </td>
<td width="124"> </td>
<td width="124"> </td>
<td width="124" align="center"><a href="../../add admin users/changePasword.php">Change Password</a></td>
<td width="129" align="center"><a href="../../Home page/new student registration/signout.php">Signout</a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="59" valign="top"><table width="170" border="1" bordercolor="#000000">
<tr>
<td width="162"><a href="../../add admin users/add techer/addAdminUser.php">
<label>Add Admin Login</label>
</a></td>
</tr>
<tr>
<td><a href="../../add admin users/manage teacher/searchAdminUser.php">
<label>Manage Addmin Login</label>
</a></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><label>Add Student</label>
</td>
</tr>
<tr>
<td><a href="../manage student details/manageStudentDetails.php">
<label>Manage Student</label>
</a></td>
</tr>
<tr>
<td><a href="../../student attendance/add attendance/addStudentAttendance.php">
<label>Add Student Attendance </label>
</a></td>
</tr>
<tr>
<td><a href="../../student attendance/manage attendance/manageStudentAttendance.php">
<label>Manage Student Attendance </label>
</a></td>
</tr>
<tr>
<td><a href="../../Student time table/add1 time table/addTimeTable.php">
<label>Add Time Table</label>
</a></td>
</tr>
<tr>
<td><a href="../../Student time table/maange time table/manageTimeTable.php">
<label>Manage Time Table</label>
</a></td>
</tr>
<tr>
<td><a href="../../Student marks/add student marks/addStudentMark.php">
<label>Add Student Marks</label>
</a></td>
</tr>
<tr>
<td><a href="../../Student marks/manage stdent marks/manageStudentMark.php">
<label>Manage Student Marks</label>
</a></td>
</tr>
<tr>
<td><a href="../../manage subject/add subject.php">
<label>Add Subject</label>
</a></td>
</tr>
<tr>
<td><a href="../../manage subject/manage subject.php">
<label>Manage Subject</label>
</a></td>
</tr>
<tr>
<td><a href="../../search student information/SearchStudentInformation.php">
<label>Search Student Information</label>
</a></td>
</tr>
<tr>
<td><a href="../../manage students grade/manage student grade.php">
<label>Manage Student Grade</label>
</a></td>
</tr>
<tr>
<td><a href="../../manage student class/manageStudentClass.php">
<label>Manage Student Class</label>
</a></td>
</tr>
<tr>
<td><a href="../../manage student payment/manageStudentsPayments.php">
<label>Manage Student Payment</label>
</a></td>
</tr>
<tr>
<td><a href="../../home management/home management.php">
<label>Manage Home Page</label>
</a></td>
</tr>
<tr>
<td><a href="../../student payments reports/studentsPayments.php">
<label>Student Payment Reports</label>
</a></td>
</tr>
<tr>
<td><a href="../../Issue certificate/issueCertificate.php">
<label>Issue Certificate</label>
</a></td>
</tr>
</table></td>
<td><table width="633" border="0">
<tr>
<td> </td>
<td colspan="5"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="9"> </td>
<td colspan="5"><h3>
<label><strong>Add Student Information</strong></label>
<strong> </strong></h3></td>
<td width="13"> </td>
<td width="19"> </td>
<td width="51"> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td colspan="3"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td colspan="3"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Admission Number </label> </td>
<td colspan="3">
<input type="text" name="admission_no" id="textfield" /> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Admission Date</label> </td>
<td colspan="5">
<input type="text" name="admission_date" id="admission_date" /><a href="javascript:NewCssCal('admission_date','yyyymmdd')">
<img src="images/cal.gif"alt="Pick a date" width="16" height="16" border="0"></a> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Student Full Name </label> </td>
<td colspan="3">
<textarea name="full_name" id="textfield2"></textarea> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Student Name With Initials </label> </td>
<td colspan="3">
<input type="text" name="name_with_initial" id="textfield3" /> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Date of Birth </label> </td>
<td colspan="3"><input type="text" name="date_of_birth" id="date_of_birth" /><a href="javascript:NewCssCal('date_of_birth','yyyymmdd')">
<img src="images/cal.gif"alt="Pick a date" width="16" height="16" border="0"></a></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Religion </label> </td>
<td colspan="3"><label>
<select name="religion" id="select2">
<option selected="selected"></option>
<option>Buddhism</option>
<option>Cathelic</option>
<option>Roman Cathelic</option>
<option>Muslim</option>
<option>Hindu</option>
<option>Other</option>
</select>
</label></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr> </tr>
<tr>
<td> </td>
<td colspan="2"><label>Address </label> </td>
<td colspan="3">
<textarea name="address" id="textarea" cols="45" rows="5"></textarea> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Telephone Number </label> </td>
<td colspan="3">
<input type="text" name="telephone" id="textfield6" /> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Grade on Admission </label> </td>
<td colspan="3">
<select name="grade_on_admission" id="jumpMenu" >
<?PHP
$query="SELECT * FROM grade ";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo "<option value=\"".$row['grade_id']."\">".$row['grade']."</option> \n ";
}
?>
</select> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Present Grade</label> </td>
<td width="113">
<select name="grade_ID" id="jumpMenu2" onchange="changestream()" >
<?php
$query="SELECT * FROM grade ";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo "<option value=\"".$row['grade_id']."\">".$row['grade']."</option> \n ";
}
?>
</select> </td>
<td width="59"><label>Stream</label> </td>
<td>
<select name="stream_ID" id="jumpMenu4" disabled="disabled">
<option selected="selected"></option>
<option>Maths</option>
<option>Science</option>
<option>Commerce</option>
<option>Art</option>
</select> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Present Class</label> </td>
<td colspan="3">
<select name="class_ID" id="jumpMenu3" >
<option selected="selected"></option>
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
<option>E</option>
<option>F</option>
<option>G</option>
<option>H</option>
<option>I</option>
<option>J</option>
<option>K</option>
<option>L</option>
<option>M</option>
<option>N</option>
<option>O</option>
<option>P</option>
<option>Q</option>
<option>R</option>
<option>S</option>
<option>T</option>
<option>U</option>
<option>V</option>
<option>W</option>
<option>X</option>
<option>Y</option>
<option>Z</option>
</select> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Student House</label> </td>
<td colspan="3">
<select name="student_house" id="select">
<option selected="selected"></option>
<option>PARAVI</option>
<option>HANSA</option>
<option>GIRA</option>
<option>KOKILA</option>
</select> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>School payments</label> </td>
<td colspan="3">
<input type="radio" name="payment" id="radio3" value="2000" />
yes
<input type="radio" name="payment" id="radio4" value="0" checked="checked"/>
no </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Password</label> </td>
<td colspan="3">
<input type="password" name="password" id="textfield8" /> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Confirm Password</label></td>
<td colspan="3">
<input type="password" name="ConfirmPassword" id="textfield9" /> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><label>Student Description</label> </td>
<td colspan="3">
<textarea name="description_about_st" id="textarea2" cols="45" rows="5">
</textarea> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td colspan="3"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td colspan="3">
<input type="submit" name="button3" id="button3" value="Save" onClick="return Validate();"/> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
<td colspan="3"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
<p> </p></td>
</tr>
</table>
</form>
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'];
$address=$_POST['address'];
$telephone=$_POST['telephone'];
$grade_on_admission=$_POST['grade_on_admission'];
$grade_ID=$_POST['grade_ID'];
$stream_ID=isset($_POST['stream_ID']) ? $_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
$answer='';
$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);
while($row=mysql_fetch_array($result)){
$answer=$row['admission_no'];}
if($answer==0)
{
header("location:studentregistrationDatabase.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 alredy entered to the system ."."<BR>"."<BR>"."<BR>";
echo "<a href='newStudentRegistrationForm.php'>GO to manage student details page</a> ";
exit();
}?>
studentregistrationDatabase.php
<?PHP
$admission_no=isset($_POST['admission_no']) ? $_POST['admission_no'] :'';
$admission_date=isset($_POST['admission_date']) ? $_POST['admission_date'] :'';
$full_name=isset($_POST['full_name']) ? $_POST['full_name'] :'';
$name_with_initials=isset($_POST['name_with_initial']) ? $_POST['name_with_initial'] :'';
$dob=isset($_POST['date_of_birth']) ? $_POST['date_of_birth'] :'';
$religion=isset($_POST['religion']) ? $_POST['religion'] :'';
$address=isset($_POST['address']) ? $_POST['address'] :'';
$telephone=isset($_POST['telephone']) ? $_POST['telephone'] :'';
$grade_on_admission=isset($_POST['grade_on_admission']) ? $_POST['grade_on_admission'] :'';
$present_grade=isset($_POST['grade_ID']) ? $_POST['grade_ID'] :'';
$stream=isset($_POST['stream_ID']) ? $_POST['stream_ID'] :'';
$present_class=isset($_POST['class_ID']) ? $_POST['class_ID'] :'';
$student_house=isset($_POST['student_house']) ? $_POST['student_house'] :'';
$password=isset($_POST['password']) ? $_POST['password'] :'';
$description_about_st=isset($_POST['description_about_st']) ? $_POST['description_about_st'] :'';
$payment=isset($_POST["payment"]) ? $_POST["payment"] :'';
$current=getdate(time());
$year=$current["year"];
$today = date("Y-m-d");
$con=mysql_connect("localhost","root","");
mysql_select_db("student_management",$con);
//insert to database
$query="select count(*) from student_info where admission_no='$admission_no'";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
if($row[0]==0)
{
$query="INSERT INTO student_info values('$admission_no','$admission_date','$full_name','$name_with_initials','$dob','$religion','$address','$telephone','$grade_on_admission','$password','$student_house','$description_about_st')";
$result=mysql_query($query);
if($stream!=null){
$query="select class_id from class
where class.grade_id='$present_grade' and class.class_name='$present_class' and class.stream='$stream'";
}else{
$query="select class_id from class
where class.grade_id='$present_grade' and class.class_name='$present_class'";
}
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$class_id=$row['class_id'];
}
$query="insert into student_class values('$admission_no','$class_id','$year')";
$result=mysql_query($query);
if($payment=="2000")
{
$query="insert into payment_amount values(null,'2000','$today')";
$result=mysql_query($query);
$query="SELECT amount_id FROM payment_amount order by amount_id DESC limit 1";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
$amount_id=$row['amount_id'];
}
$query="insert into payment values('$admission_no','$amount_id')";
$result=mysql_query($query);
}else{
$query="insert into payment_amount values(null,'0','$today')";
$result=mysql_query($query);
$query="SELECT amount_id FROM payment_amount order by amount_id DESC limit 1";
$result=mysql_query($query);
while($row = mysql_fetch_array($result))
{
$amount_id=$row['amount_id'];
}
$query="insert into payment values('$admission_no','$amount_id')";
$result=mysql_query($query);
}
header("location:../new student registration-parent details/studentRegistrationParentDetailsForm.php?admission_no=".$admission_no);
exit();
}
else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
</body>
<?php
echo "Admission number".$admission_no."This student has been already entered to the system"."<BR>"."<BR>"."<BR>";
echo "<a href='newSstudentRegistrationForm.php'>GO to registration page</a>";
exit();
}
?>