You are on page 1of 25

Table Details:

Student table:

Courses Table:
Question Table:
Adminlogin Table:
Receipt Table (Values updated automatically after allocation)
Student Login Table:
Output:
Changes in the code:

Admin Login

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Welcome</title>

</head>
<body background="images.jpg">

<h1 style="text-align: center;">University Admission Admin Portal</h1>

<br>

<?php session_start(); if (!isset($_REQUEST['username']))

{ echo'

<font size=5>

<center>

<form action="" method="post">

<br>

<br>

<br>

<br>

<br>

Username: <input type="text" name="username" id="username"


required> <br><br>

Password: <input type="password" name="password"


id="password" required> <br><br>

<input type="submit" value="LOGIN">

</form>

</font>

</center> '; }

else {

$username = $_REQUEST['username'];

$password = $_REQUEST['password'];

$pdo = new PDO('mysql:host=localhost;dbname=student_admission', 'root', '');

$sql = "SELECT Password FROM adminlogin WHERE Username = '$username'";

$result = $pdo->query($sql);

$output = $result->fetch();

$_SESSION['Username'] = "$username";

if($output['Password']== $password)

header('Location:ADMIN_MAIN.html.php');

else
header('Location:ADMIN_LOGIN.html.php');

?>

</body>

</html>

Admin Main

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Welcome</title>

</head>

<body background="images.jpg">

<h1 style="text-align: center;">University Admission Admin Portal</h1>

<br><br><br><br>

<font size="6" color="blue">

<a href="ADMIN_LOGIN.html.php">Log Out</a>

</font>

<br> <br>

<?php

session_start();

$compute_rank=0;

$pdo = new PDO('mysql:host=localhost;dbname=student_admission', 'root','');

if(!isset($_REQUEST['password']))

{ echo'

<font size=5>

<center>

<form action="" method="post">

<h4 style="text-align: center;">Compute Student Rank</h4>

<br>
Student Password: <input type="password" name="password" id="password" required>

<br>

<input type="submit" value="Compute Rank">

<br><br>

</form>

</font>

</center> '; }

else {

$sql = "SELECT * FROM Student ORDER BY score DESC,board_mark DESC";

$result = $pdo->query($sql);

$i=0;

echo "regno"." "."name"." "."Rank";

echo "<br><br><br>";

$i=0;

while($row = $result->fetch())

$i++;

$regno=$row['RNO'];

$name=$row['name'];

$rank=$row['rank']=$i;

echo "$regno"." "."$name"." "."$rank";

$sql1="UPDATE `Student` SET `rank` = '$i' WHERE `Student`.`RNO` ='$regno'";

$result= $pdo->query($sql1);

echo "<br><br><br>";

$compute_rank=0;

if(!isset($_REQUEST['password1']))

echo'

<font size=5>
<center>

<form action="" method="post">

<h4 style="text-align: center;">Course Allocation</h4>

<br>

Student Password:

<input type="password" name="password1" id="password1" required>

<br>

<input type="submit" value="start allotment">

<br><br>

</form>

</font>

</center> '; }

else

$pdo = new PDO('mysql:host=localhost;dbname=student_admission', 'root','');

$sql = "SELECT * FROM Student ORDER BY rank ";

$result = $pdo->query($sql);

$i=0;

echo "regno"." "."name"." "."Rank"." "."alloted";

echo "<br><br><br>";

$i=0;

while($row = $result->fetch())

$sqle="";

$regno=$row['RNO'];

$name=$row['name'];

$pf1=$row['pref1'];

$pf2=$row['pref2'];

$rank=$row['rank'];

$alloted=0;

$sql1="select * from Courses where CCODE= '$pf1'";


$result1=$pdo->query($sql1); $row1=$result1->fetch();

$sql2="select * from Courses where CCODE= '$pf2'";

$result2=$pdo->query($sql2);

$row2=$result2->fetch();

if(strcmp($row['reser'],"YES")==0)

$flag=0;

if($row1['reser']>0)

$alloted=$row1['CCODE'];

$reser=$row1['reser']-1;

$sqle="UPDATE Courses SET reser ='$reser' where CCODE ='$pf1'";

$flag=1;

else if ($row1['avail']>0)

$alloted=$row1['id'];

$avail=$row1['avail']-1;

$sqle="UPDATE Courses SET avail ='$avail' where CCODE ='$pf1'";

$flag=1;

else if($row2['reser']>0)

$alloted=$row2['CCODE'];

$reser=$row2['reser']-1;

$sqle="UPDATE Courses SET reser ='$reser'where CCODE ='$pf2'";

$flag=2;

else if ($row2['avail']>0)

$alloted=$row2['CCODE'];
$avail=$row2['avail']-1;

$sqle="UPDATE Courses SET avail ='$avail' where CCODE ='$pf2'";

$flag=2;

else

if ($row1['avail']>0)

$alloted=$row1['CCODE'];

$avail=$row1['avail']-1;

$sqle="UPDATE Courses SET avail ='$avail' where CCODE ='$pf1'";

$flag=1;

else if($row2['avail']>0)

$alloted=$row2['CCODE'];

$avail=$row2['avail']-1;

$sqle="UPDATE Courses SET avail ='$avail' where CCODE ='$pf2'";

$flag=2;

if($flag==1)

$cname=$row1['CNAME'];

$sqle1="UPDATE Student SET allot='$pf1' where RNO='$regno'";

echo "$regno\t$name\t$rank\t$cname\t\n";

elseif ($flag==2)

$sqle1="UPDATE Student SET allot='$pf2' where RNO='$regno'";


$cname=$row2['CNAME'];

echo "$regno\t$name\t$rank\t$cname\t\n";

$result3 = $pdo->query($sqle);

$result4 = $pdo->query($sqle1);

?>

</body>

</html>

Login

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Welcome</title>

</head>

<body background="images.jpg">

<h1 style="text-align: center;">University Admission Portal</h1>

<h2 style="text-align: center;">Security Question</h2>

<?php session_start();

$regno=$_SESSION['regno'];

$pdo = new PDO('mysql:host=localhost;dbname=student_admission', 'root','');

$sql="select * from Student where RNO= '$regno'";

$result=$pdo->query($sql);

$row=$result->fetch();

$name=$row["name"];

$sex=$row['GENDER'];

$pref1=$row['pref1'];

$pref2=$row['pref2'];
$reser=$row['reser'];

$atte=$row['atte'];

$rank=$row['rank'];

$allot=$row['allot'];

$re=$row['recp'];

$score=$row['score'];

$pdo1 = new PDO('mysql:host=localhost;dbname=student_admission', 'root','');

$sql1="select * from Courses where CCODE= '$pref1'";

$result1=$pdo1->query($sql1);

$row1=$result1->fetch();

$sql2="select * from Courses where CCODE= '$pref2'";

$result2=$pdo->query($sql2);

$row2=$result2->fetch();

$pfname1=$row1['CNAME'];

$pfname2=$row2['CNAME'];

if (strcmp($atte,"YES")==0)

$score=$row['score'];

else

$score="not yet calculated";

if (strcmp($allot,NULL)==0)

$allot="NOT YET ALLOTED";

?>

<br>

<h1 style="text-align: center;"><?php echo "$name"." "."$regno" ?></h1>

<font size="6" color="black">


<br>

<a href="MAIN.html.php">Log Out</a>

</font>

<br> <br> <br>

<h3 style="text-align: left;" ><?php echo "Name :"." "."$name" ?></h3>

<h3 style="text-align: left;"><?php echo "Sex :"." "."$sex" ?></h3>

<h3 style="text-align: left;"><?php echo "Preference no 1 : "."$pfname1" ?></h3>

<h3 style="text-align: left;"><?php echo "Preference no 2 : "."$pfname2" ?></h3>

<h3 style="text-align: left;"><?php echo "Reservation :"." "."$reser" ?></h3>

<h3 style="text-align: left;"><?php echo "Receipt no : "." "."$re" ?></h3>

<h3 style="text-align: left;"><?php echo "Score :"." "."$score" ?></h3>

<h3 style="text-align: left;"><?php echo "Rank :"." "."$rank" ?></h3>

<h3 style="text-align: left;"><?php echo "Alloted :"." "."$allot" ?></h3>

<br> <br>

<form name="testForm" id="testForm" method="POST" >

<input type="submit" name="btn" value="Test" onclick="return true;"/>

</form>

<br> <br> <br> <br>

<form name="testForm" id="testForm1" method="POST" >

<input type="submit" name="rec" value="Generate receipt" onclick="return true";/>

</form>

<?php

if(isset($_REQUEST['btn']))

if (strcmp($atte,"no")==0)

header('Location:MAIN.html.php');

else

$_SESSION['btn']="$score";
header('location :TEST.html.php');

if(isset($_REQUEST['rec']))

if ($allot == NULL||strcmp( $allot,"NOT YET ALLOTED")==0)

header('Location:MAIN.html.php');

else

$_SESSION['rec'] = "$re";

header('location:RECEIPT.php');

?>

<br>

</body>

</html>

Main:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Welcome</title>

</head>

<body background="images.jpg">

<h1 style="text-align: center;">Students Portal</h1>

<?php
session_start();

if (!isset($_REQUEST['regno']))

echo'

<font size=5>

<center>

<form action="" method="post">

<br><br><br><br><br>Reg no: <input type="text" name="regno" id="regno" required>

<br><br>Password: <input type="password" name="password" id="password" required>

<br><br><input type="submit" value="GO">

</form>

</font>

</center>

';

else

$regno = $_REQUEST['regno'];

$password = $_REQUEST['password'];

$pdo = new PDO('mysql:host=localhost;dbname=student_admission', 'root','');

$sql = "SELECT PASSWORD FROM Login WHERE RNO = '$regno'";

$result = $pdo->query($sql);

$output = $result->fetch();

$_SESSION['regno'] = "$regno";

if($output['password']== $password)

header('Location:MAIN.html.php');

else

header('Location:LOGIN.php');
}

?>

</body>

</html>

Test:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Welcome</title>

</head>

<body background="images.jpg">

<h1 style="text-align: center;">University Admission Portal</h1>

<?php

$answer=0;

session_start();

$regno=$_SESSION['regno'];

$pdo = new PDO('mysql:host=localhost;dbname=student_admission', 'root','');

$sql="select q_id from Student where RNO= '$regno'";

$result=$pdo->query($sql);

$output = $result->fetch();

$qid=$output['q_id'];

$score=$output['score'];

$sql1 ="SELECT * FROM Question WHERE ID = '$qid'";

$result1=$pdo->query($sql1);

$answer_array=array();

$row=$result1->fetch();

if(!isset($_REQUEST['btn']))

echo '<br>';
echo '<br>';

echo $row['Question'];

echo '<br>';

echo '<br>';

echo "1 :".$row['option1'];

echo '<br>';

echo '<br>';

echo "2 :".$row['option2'];

echo '<br>';

echo '<br>';

echo "3 :".$row['option3'];

echo '<br>';

echo '<br>';

echo "4 :".$row['option4'];

echo '<br>';

echo '<br>';

echo'Answer <?php echo ; ?> :<input type="text" name="answer" id="answer<?php echo ; ?>"
required>';

array_push($answer_array,$row['Correct']);

echo'

<form name="testForm" id="testForm" method="POST" >

<input type="submit" name="btn" value="submit" autofocus onclick="return ;"/>

</form>

';

else

$score++;

$sql2="UPDATE Student SET score ='$score'";

$sql3="UPDATE Student SET atte='YES'";


$result2=$pdo->query($sql2);

?>

</body>

</html>

Receipt:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Welcome</title>

</head>

<body background="images.jpg">

<h1 style="text-align: center;">University Admission Portal</h1>

<h2 style="text-align: center;">Receipt</h2>

<?php

session_start();

$re=$_SESSION['rec'];

$regno=$_SESSION['regno'];

$pdo = new PDO('mysql:host=localhost;dbname=student_admission', 'root','');

$sql="select * from Student where RNO= '$regno'";

$result=$pdo->query($sql);

$row=$result->fetch();

$name=$row['name'];

$allot=$row['allot'];

$pdo1 = new PDO('mysql:host=localhost;dbname=student_admission', 'root','');

$sql1="select * from Courses where CCODE= '$allot'";

$result1=$pdo1->query($sql1);

$row1=$result1->fetch();

$cname=$row1['CNAME'];
$fee=$row1['fee'];

$total_fee=($fee*112)/100;

$sql2 = "insert into Receipt(Number,Name,Alloted_Code,Alloted_Name,Fee,Total_Fee) values


('$re','$name','$allot','$cname','$fee','$total_fee')";

$result2=$pdo->query($sql2);

?>

<br>

<h4 style="text-align: center;"><?php echo "$name"." "."$regno" ?></h4>

<font size="4" color="black">

<br>

<br>

<br>

<h4 style="text-align: left;"><?php echo "Receipt no:"." "."$re" ?></h4>

<h4 style="text-align: left;"><?php echo "Name :"." "."$name" ?></h4>

<h4 style="text-align: left;"><?php echo "code:"." "."$allot" ?></h4>

<h4 style="text-align: left;"><?php echo "course name: "."$cname" ?></h4>

<h4 style="text-align: left;"><?php echo "fee : "."$fee" ?></h4>

<h4 style="text-align: left;"><?php echo "tax : 12%" ?></h4>

<h4 style="text-align: left;"><?php echo "total fee"." "."$total_fee" ?></h4>

>

<br>

<br>

<br>

<br>

</body>

</html>

You might also like