any one can fix this code's error
HTML:
<html>
<head>
<title>Course Progession</title>
<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>
<body>
<?php
$firstName = @$_POST["Firstname"];
$surName = @$_POST["Surname"];
$studentId = @$_POST["StudentID"];
$courseType = @$_POST["CourseType"];
//dim $unitCode;
$unitCode = array($_POST["UnitCode_1"], $_POST["UnitCode_2"], $_POST["UnitCode_3"], $_POST["UnitCode_4"], $_POST["UnitCode_5"], $_POST["UnitCode_6"], $_POST["UnitCode_7"], $_POST["UnitCode_8"], $_POST["UnitCode_9"], $_POST["UnitCode_10"], $_POST["UnitCode_11"], $_POST["UnitCode_12"], $_POST["UnitCode_13"], $_POST["UnitCode_14"], $_POST["UnitCode_15"], $_POST["UnitCode_16"], $_POST["UnitCode_17"], $_POST["UnitCode_18"], $_POST["UnitCode_19"], $_POST["UnitCode_20"], $_POST["UnitCode_21"], $_POST["UnitCode_22"], $_POST["UnitCode_23"], $_POST["UnitCode_24"], $_POST["UnitCode_25"], $_POST["UnitCode_26"], $_POST["UnitCode_27"], $_POST["UnitCode_28"], $_POST["UnitCode_29"], $_POST["UnitCode_30"]);
//dim $noOfCreditPoints;
$noOfCreditPoints = array(@$_POST["CP_1"], $_POST["CP_2"], $_POST["CP_3"], $_POST["CP_4"], $_POST["CP_5"], $_POST["CP_6"], $_POST["CP_7"], $_POST["CP_8"], $_POST["CP_9"], $_POST["CP_10"], $_POST["CP_11"], $_POST["CP_12"], $_POST["CP_13"], $_POST["CP_14"], $_POST["CP_15"], $_POST["CP_16"], $_POST["CP_17"], $_POST["CP_18"], $_POST["CP_19"], $_POST["CP_20"], $_POST["CP_21"], $_POST["CP_22"], $_POST["CP_23"], $_POST["CP_24"], $_POST["CP_25"], $_POST["CP_26"], $_POST["CP_27"], $_POST["CP_28"], $_POST["CP_29"], $_POST["CP_30"]);
//dim $semester;
$semester = array(@$_POST["YS_1"], $_POST["YS_2"], $_POST["YS_3"], $_POST["YS_4"], $_POST["YS_5"], $_POST["YS_6"], $_POST["YS_7"], $_POST["YS_8"], $_POST["YS_9"], $_POST["YS_10"], $_POST["YS_11"], $_POST["YS_12"], $_POST["YS_13"], $_POST["YS_14"], $_POST["YS_15"], $_POST["YS_16"], $_POST["YS_17"], $_POST["YS_18"], $_POST["YS_19"], $_POST["YS_20"], $_POST["YS_21"], $_POST["YS_22"], $_POST["YS_23"], $_POST["YS_24"], $_POST["YS_25"], $_POST["YS_26"], $_POST["YS_27"], $_POST["YS_28"], $_POST["YS_29"], $_POST["YS_30"]);
//dim $marks;
$marks = array(@$_POST["UM_1"], $_POST["UM_2"], $_POST["UM_3"], $_POST["UM_4"], $_POST["UM_5"], $_POST["UM_6"], $_POST["UM_7"], $_POST["UM_8"], $_POST["UM_9"], $_POST["UM_10"], $_POST["UM_11"], $_POST["UM_12"], $_POST["UM_13"], $_POST["UM_14"], $_POST["UM_15"], $_POST["UM_16"], $_POST["UM_17"], $_POST["UM_18"], $_POST["UM_19"], $_POST["UM_20"], $_POST["UM_21"], $_POST["UM_22"], $_POST["UM_23"], $_POST["UM_24"], $_POST["UM_25"], $_POST["UM_26"], $_POST["UM_27"], $_POST["UM_28"], $_POST["UM_29"], $_POST["UM_30"]); //Getting the marks
$anyError = false;
$unitsAttempted = 0;
$passedUnits = 0;
$totalCreditPoints = 0;
$totalMarks = 0;
function validateStudentInfo($fName, $sName, $stdId) {
if($fName == NULL){
echo "Please enter your Firstname <br />";
$anyError = true;
}
if($sName == NULL){
echo "Please enter your Surname <br />";
$anyError = true;
}
if($stdId == NULL){
echo "Please enter your Student ID <br />";
$anyError = true;
}
if($stdId <> NULL){
//dim $sID;
$sID = strlen($stdId);
if(($sID<8) OR (!is_numeric($stdId))){
echo "Please re-enter the Student ID, Student ID must be a 8 digit numeric <br />";
$anyError = true;
}
}
}
function displayStudentDetails ($fName, $sName, $stdId) {
echo "Name : ".($fName)." ".($sName);
echo "<br />Student ID : ".($stdId);
}
function displayCourseDetails($course) {
if($course == 1){
echo "<br /><br />You have chosen the Undergraduate Program";
}
if($course == 2){
echo "<br /><br />You have chosen the Graduate Diploma Program";
}
if($course == 3){
echo "<br /><br />You have chosen the Masters by Coursework Program";
}
if($course == 4){
echo "<br /><br />You have chosen the Masters by Research Program";
}
}
function validateCourseInfo($uCode, $cPoints, $sem, $mark) {
for ($counter=0; $counter<=29; $counter++) {
if(($uCode[$counter] <> NULL)AND($cPoints[$counter] <> "")AND($sem[$counter] <> "")AND($mark[$counter] <> ""))then;
//dim $uC;
$uC = strlen($uCode[$counter]);
if($uC <> 7)then;
echo "<br />Please check row number ".($counter+1);
echo "<br />Unitcode should consist of 7 digits<br />";
$anyError = true;
}
if(is_numeric($cPoints[$counter])){
if(($cPoints[$counter] <> 20) AND ($cPoints[$counter] <> 15)){
echo "<br />Please check row number ".($counter+1);
echo "<br />Credit points only be either 15 or 20<br />";
$anyError = true;
}
} else {
echo "<br />Please check row number ".($counter+1);
echo "<br />Credit points only be either 15 or 20<br />";
$anyError = true;
}
//dim $smstr;
$smstr = strlen($sem[$counter]);
if (($smstr <> 3)OR(! is_numeric($sem[$counter]))){
echo "<br />Please check row number ".($counter+1);
echo "<br />Semester must be a 3 digits numeric<br />";
$anyError = true;
}
if(is_numeric($mark[$counter])){
if($mark[$counter] > 100 OR 0 >= $mark[$counter]){
echo "<br />Please check row number ".($counter+1);
echo "<br />Marks should be less than 100 or greater than 0<br />";
$anyError = true;
}
} else {
echo "<br />Please check row number ".($counter+1);
echo "<br />Marks should be less than 100 or greater than 0<br />";
$anyError = true;
}
function findAndCalculateCourseDetails($cPoints, $mark) {
for ($counter=0; $counter<=29; $counter++) {
if($mark[$counter]<>NULL){
if($mark[$counter]<=100 AND $mark[$counter]>=0)then;
$unitsAttempted = $unitsAttempted+1;
$totalMarks = $totalMarks + $mark[$counter];
if($mark[$counter]>=50){
$numberOfPassedUnits = $numberOfPassedUnits+1;
$totalCreditPoints = $totalCreditPoints+$cPoints[$counter];
}
}
}
}
echo "<br /><br />You have Total of ".$totalMarks." Marks";
echo "<br />Your have ".totalCreditPoints." credit points";
echo "<br /><br />You have attempted ".$unitsAttempted." times";
echo "<br />You have successlully completed ".numberOfPassedUnits." units";
}
function calculateRequiredCreditPoints ($totalCreditPoints, $course) {
//dim $pointsRequired;
if($course == 1){
$pointsRequired = 360 - $totalCreditPoints;
}
if($course == 2){
$pointsRequired = 120 - $totalCreditPoints;
}
if($course == 3){
$pointsRequired = 180 - $totalCreditPoints;
}
if($course == 4){
$pointsRequired = 240 - $totalCreditPoints;
}
if($pointsRequired > 0){
echo "<br /><br />You Need Another ".$pointsRequired." marks to complete the selected program";
} else {
echo "<br /><br />Congratulations!! You have successfully completed the selected program";
}
}
function calculateCourseAvg ($totalMarks, $unitsAttempted) {
if($unitsAttempted>0){
//dim $average;
$average = $totalMarks/$unitsAttempted;
if($average <50){
echo "<br /><br />Your Average is ".$average." and Your Grade is F - Fail";
} elseif($average <60){
echo "<br /><br />Your Average is ".$average." and Your Grade is C - Simple Pass";
} elseif($average <70){
echo "<br /><br />Your Average is ".$average." and Your Grade is Cr - Credit pass";
} elseif($average <80){
echo "<br /><br />Your Average is ".$average." and Your Grade is D - Distinction";
} else {
echo "<br /><br />Your Average is ".$average." and Your Grade is HD - High Distinction";
}
}
} //
validateStudentInfo($firstName, $surName, $studentId);
validateCourseInfo($unitCode, $noOfCreditPoints, $semester, $marks);
if($anyError == false){
displayStudentDetails($firstName, $surName, $studentId);
displayCourseDetails($courseType);
findAndCalculateCourseDetails($noOfCreditPoints, $marks);
calculateRequiredCreditPoints (totalCreditPoints, $courseType);
calculateCourseAvg ($totalMarks, $unitsAttempted);
}
?>
</body>
</html>