Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

To Implement Rep Allocation System Using PHP, HTML, Css and Mysql

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Exp.

No: 12 REP ALLOCATION SYSTEM


Date:

Aim:
To implement Rep Allocation system using php, html, css and Mysql.
Code:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "rep";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: ".$conn->connect_error);
}
// echo "Successfully connected to database, " . $dbname;
?>

<?php
session_start();
include 'db.php';
include 'tables.php';

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Representative Selection System</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="./style.css">
<style>
/* CSS for the loading animation */
#loading {
display: none;
position: fixed;
z-index: 9999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(10, 10, 10, 0.9); /* semi-transparent white background */
text-align: center;

}
#loading img {
margin-top: 20%;
}
</style>
</head>
<body>
<div id="loading">
<img src="loading.gif" alt="Loading...">
</div>

<footer class="bg-light mt-2 py-3">


<small style="float: left;" class="ml-5">Copyright &copy 2021 PSG iTech SDC v1.2</small>
<small style="float: right;" class="mr-5">Developed By: Praveen Barathi K and Kalyan Kumar S -
CSE[2022-2026]</small>
</footer>
<script>
function showLoading() {
document.getElementById("loading").style.display = "block";
setTimeout(function() {
document.getElementById("loading").style.display = "none";
}, 6000); // Hide loading after 6 seconds (adjust as needed)
}
</script>
</body>
</html><?php
session_start();
include 'db.php';
include 'tables.php';
?>
<?php
if($start_time > $now){
$regblock = $guideblock = $teamblock = $b = $s = "none";
$time_block = "block";
} else if($now > $stop_time) {
$regblock = $guideblock = $teamblock = $b = $s = "none";
$time_block = "block";
// $sql = "SELECT * FROM batches WHERE guide_name = NULL";
// $team = $conn->query($sql);
// $sql = "SELECT * FROM guide WHERE available > 0";
// $guide = $conn->query($sql);
} else {
$s = $guideblock = $teamblock = $b = "none";
$regblock = "block";
$do_this = 0;
$time_block = "none";
// $gnameb = $gnameg ="";

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Rep Selection System</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="alert alert-danger" style="display: <?php echo $b ?>;">
<strong>Warning!</strong> <?php echo $bcontent ?>
</div>

<div class="alert alert-success" style="display: <?php echo $s ?>;">


<strong>Success!</strong> Voting Process Completed.

<div class="row mt-5 w-100" style="display: <?php echo $time_block ?>;">


<div class="container col-lg-3 col-md-5 p-5" style="background-color: rgba(255,0,0,0.1);">
<h3 class="text-danger">Please try again in the given time</h3>
</div>
</div>
<div class="row mt-5" style="display: <?php echo $regblock ?>;">
<div class="container col-lg-3 col-md-5">
<form class="form-inline p-5 shadow-lg" action="" method="post" style="background-color:
rgba(255,255,255,0.3);">
<input type="text" class="form-control col-12 mb-2 mr-sm-2" placeholder="Enter Register Number"
name="regno">
<button type="submit" name="reg_submit" class="btn btn-success mb-2 px-5 col-12">Submit</button>
</form>
</div>
</div>
<div class="row mt-5" style="display: <?php echo $teamblock ?>;">
<div class="col-md-4 container bg-light py-4 px-4 shadow-lg" style="border-radius: 10%;">
<h3>Your Details</h3>
<table class="table table-borderless">
<tbody>
<?php
if($do_this){
$sql = "SELECT * FROM batches where group_no = '" . $_SESSION["group"] . "'";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()){
echo "<tr>";
echo "<td>" . $row["reg_no"] . "</td>";
echo "<td>" . $row["student_name"] . "</td>";
echo "</tr>";
if($row["guide_name"]){
$guide_name = "Voting process completed";
} else {
$guide_name = "Yet to vote";
}
}
$do_this = 0;
}
?>
</tbody>
</table>
<?php
echo "<h3>Status</h3>";
echo "<legend>" . $guide_name . "</legend>";
?>
</div>
</div>
<div class="row mt-5" style="display: <?php echo $guideblock ?>;">
<div class="col-md-6 container bg-light py-4 px-4 shadow-lg" style="border-radius: 10%;">
<h3>Boys Representatives </h3>
<table class="table table-bordered mt-4">
<thead>
<tr>
<th>Names</th>
<th>Register Number</th>
<th>VOTE</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM guide where available > 0 AND total_project = 1";
$result = $conn->query($sql);
if($result->num_rows != 0){
while($row = $result->fetch_assoc()){
echo "<tr>";
echo "<td>" . $row['guide_name'] . "</td>";
echo "<td>" . $row['reg_no'] . "</td>";
echo " <form method='post' action=''><td><input type='radio' name='selected_boy' value='" .
$row['guide_name'] ."'></td><form>";
echo "</tr>";
}
}
?>
</tbody>
</table>
</div>
</div>
<div class="row mt-5" style="display: <?php echo $guideblock ?>;">
<div class="col-md-6 container bg-light py-4 px-4 shadow-lg" style="border-radius: 10%;">
<h3>Girl Representatives </h3>
<table class="table table-bordered mt-4">
<thead>
<tr>
<th>Names</th>
<th>Register Number</th>
<th>VOTE</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM guide WHERE available > 0 AND total_project = 4";
$result = $conn->query($sql);
if($result->num_rows != 0){
while($row = $result->fetch_assoc()){
echo "<tr>";
echo "<td>" . $row['guide_name'] . "</td>";
echo "<td>" . $row['reg_no'] . "</td>";
echo " <form method='post' action=''><td><input type='radio' name='selected_girl' value='" .
$row['guide_name'] ."'></td><form>";
echo "</tr>";
}
}
?>
</tbody>
</table>
<form method="post" action=""><button type="submit" name="req" class="btn
btn-primary">Submit</button></form>
</div>
</div>
<footer class="bg-light mt-2 py-3">
<small style="float: left;" class="ml-5">Copyright &copy 2021 PSG iTech SDC v1.2</small>
<small style="float: right;" class="mr-5">Developed By: Praveen Barathi K and Kalyan Kumar S -
CSE[2022-2026]</small>
</footer>
</body>
</html>

<?php include 'db.php'?>


<?php

$sql = "CREATE TABLE IF NOT EXISTS batches (


id INT NOT NULL AUTO_INCREMENT ,
reg_no VARCHAR(12) NOT NULL ,
student_name VARCHAR(30) NOT NULL ,
group_no INT NOT NULL,
guide_name VARCHAR(30) NULL DEFAULT NULL ,
status VARCHAR(10) NOT NULL DEFAULT 'PENDING' ,
otp INT,
gmail VARCHAR(40) NOT NULL,
PRIMARY KEY (`id`)
)";
$conn-> query($sql);

$sql = "CREATE TABLE IF NOT EXISTS guide (


id INT NOT NULL AUTO_INCREMENT ,
guide_name VARCHAR(30) NOT NULL ,
ren_no BIGINT(12) NOT NULL,
total_project INT NOT NULL ,
available INT NOT NULL ,
groups VARCHAR(50) NULL DEFAULT NULL ,
PRIMARY KEY (`id`)
)";
$conn->query($sql);
?>

Output:
Result:

Thus, the above code of Rep Allocation system has completed


successfully.

You might also like