Você está na página 1de 15

Source code

conn.php

<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$conn = mysqli_connect("localhost", "root", "", "hostel");
if (mysqli_connect_error()) {
die("Database Connection Error.");
}
?>

Index.php

<!DOCTYPE html>
<html>
<head>

<!--Title -->
<title>Project</title>

<!--Meta tag-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!--Link -->
<link rel="stylesheet" href="css/bootstrap1.min.css">
<link href="css/bootstrap2.css" rel="stylesheet">
<script src="<?php echo webPath;?>js/jquery.toaster.js"></script>
<link rel="stylesheet" href="css/style.css">

</head>

<body>

<!--Header-->
<nav>
<div class="nav-wrapper">
<a class="brand-logo center">M.B.M. Engineering College</a>
</div>
</nav>

<!--Logo-->
<div class="container" style="margin-top:20px;">
<div class="center">
<img src="images/M.B.M._Engineering_College_-_Logo.png" height="140px"
width="140px">
</div>
</div>

<!--Allotment-->
<div class="container" style="margin-top:20px">
<div class="row red lighten-3" style="text-align:center">

<!--Apply-->
<div class="col s12 m4 l4">
<a href="apply.php">
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="images/apply_for_it.png">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-1">Apply For Hostel<br>(1st
Year)
</div>
</div>
</a>
</div>

<!--Girls-->
<div class="col s12 m4 l4">
<a href="female.php">
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="images/girls.png">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4"> Hostel alloted list<br> (
For Girls)
</div>
</div>
</a>
</div>

<!--Boys-->
<div class="col s12 m4 l4">
<a href="male.php">
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" src="images/boys.png">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Hostel alloted list<br> ( For
Boys)
</div>
</div>
</a>
</div>
</div>
</div>
<!--Footer-->
<footer class="page-footer">
<div class="container">
<div class="row" style="margin-bottom:0px">
<div class="col l8 s12">
<h4 class="white-text"> Warden Details </h4>
<ul>
<li> Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Warden Name</li>
<li> Email-id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: warden@gmail.com</li>
<li> Phone No&nbsp;&nbsp;: 9876543212</li>
</ul>

</div>
</div>
</div>
</footer>

<?php include('message.php'); ?>


<!--Script tag-->
<script src="jquery-3.2.0.min.js"></script>
<script src="js1.min.js"></script>
</body>
</html>

Apply.php
<!DOCTYPE html>
<html lang="en">
<?php
include('conn.php');
if($_POST)
{
if(isset($_POST["apply"]))
{
$error=array();
if(isset($_POST["name"]))
{
if(empty($_POST["name"]))
{
$error["name"]="Please enter your name";
}
}
if(isset($_POST["application"]))
{
if(empty($_POST["application"]))
$error["application"]="Please enter Application number";
}
if(isset($_POST["email"]))
{
if(empty($_POST["email"]))
$error["email"]="Please enter your email-id";
}
if(isset($_POST["phone"]))
{
if(empty($_POST["phone"]))
$error["phone"]="Please enter contact number";
}
if(isset($_POST["category"]))
{
if(empty($_POST["category"]))
$error["category"]="Please enter your category";
}
if(isset($_POST["rank"]))
{
if(empty($_POST["rank"]))
$error["rank"]="Please enter JEE Main Rank";
}
if(isset($_POST["address"]))
{
if(empty($_POST["address"]))
$error["address"]="Please enter your address";
}
if(isset($_POST["pin"]))
{
if(empty($_POST["pin"]))
$error["pin"]="Please enter pincode";
}
if(isset($_POST["dob"]))
{
if(empty($_POST["dob"]))
$error["dob"]="Please enter your date of birth";
}
if(isset($_POST["gender"]))
{
if(empty($_POST["gender"]))
$error["gender"]="Please enter your gender";
}
if(isset($_POST["fname"]))
{
if(empty($_POST["fname"]))
$error["fname"]="Please enter your Father's name";
}
if(isset($_FILES["photo"]["tmp_name"]))
{
if(empty($_FILES["photo"]["tmp_name"]))
$error["photo"]="Please upload your profile pic ";
else if (!in_array(mime_content_type($_FILES["photo"]["tmp_name"]),
array("image/jpg","image/png","image/jpeg")))
{
$error["photo"] = "Please upload valid image.";
}
}
if(empty($error))
{

extract($_POST);
if (isset($_FILES["photo"]["tmp_name"])) {
$file_name = str_shuffle(md5(uniqid())) . "_" . str_replace(" ", "_", $_FILES["photo"]["name"]);
if (!empty($_FILES["photo"]["tmp_name"])) {
if (!copy($_FILES["photo"]["tmp_name"], "student" . DIRECTORY_SEPARATOR . $file_name))
{
$file_name = "";
}
}
}
if($_POST["gender"]=="male")
{
$qry="insert into male
(name,fname,application,email,phone,rank,category,address,city,state,pin,dob,gender,photo)
values
('".addslashes($name)."','".addslashes($fname)."','".addslashes($application)."','".addslashes($email)
."','".addslashes($phone)."','".addslashes($rank)."','".addslashes($category)."','".addslashes(htmlenti
ties($address))."','".addslashes($city)."','".addslashes($state)."','".addslashes($pin)."','".addslashes($
dob)."','".addslashes($gender)."','".addslashes($file_name)."')";
}
else
{
$qry="insert into female
(name,fname,application,email,phone,rank,category,address,city,state,pin,dob,gender,photo)
values
('".addslashes($name)."','".addslashes($fname)."','".addslashes($application)."','".addslashes($email)
."','".addslashes($phone)."','".addslashes($rank)."','".addslashes($category)."','".addslashes(htmlenti
ties($address))."','".addslashes($city)."','".addslashes($state)."','".addslashes($pin)."','".addslashes($
dob)."','".addslashes($gender)."','".addslashes($file_name)."')";
}
if(mysqli_query($conn,$qry))
{
$_SESSION["Message"]["Type"]="Success";
$_SESSION["Message"]["Text"]="Applied Successfully";
header("Location:index.php");
exit();
}
else
{
$_SESSION["Message"]["Type"]="Error";
$_SESSION["Message"]["Text"]="Something went wrong !! Please
try after sometime";
header("Location:index.php");
exit();
}
}
}
}

?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/plugins/morris.css" rel="stylesheet">

<script src="js/jquery.js"> </script>


<script src="js/bootstrap.min.js"> </script>

<title>Hostel Form</title>
</head>
<body>

<div class="container">
<form class="well form-horizontal" method="post" name="hostel_form" id="hostel_form"
enctype="multipart/form-data">
<fieldset>
<div style="text-align:right;margin-right:10px;font-size:24px;"><a href="index.php"> Back to
Home </a></div>

<!-- Form Name -->


<center><legend><h2>Apply For Hostel</h2></legend></center>
<!-- Fisrt Name-->

<div class="form-group">
<label class="col-md-4 control-label"> Name </label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="name" placeholder="Name" id="name" class="form-control" type="text" data-
rule-required=true>
</div>
</div>
</div>

<!-- Fisrt Name-->

<!-- Father's Name-->

<div class="form-group">
<label class="col-md-4 control-label"> Father's Name </label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="fname" placeholder="Father's Name" id="fname" class="form-control" type="text"
data-rule-required=true>
</div>
</div>
</div>

<!-- Fisrt Name-->

<!-- Application Number-->

<div class="form-group">
<label class="col-md-4 control-label">Application Number</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="application" id="application" placeholder="Enter Your Application Number"
class="form-control" type="text">
</div>
</div>
</div>

<!-- Application Number-->

<!-- Email-->
<div class="form-group">
<label class="col-md-4 control-label">E-Mail</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
<input name="email" id="email" placeholder="E-Mail Address" class="form-control" type="mail">
</div>
</div>
</div>

<!-- Email-->

<!-- Phnone Number-->

<div class="form-group">
<label class="col-md-4 control-label">Phone No. </label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
<input name="phone" id="phone" placeholder="(845)555-1212" class="form-control"
type="text">
</div>
</div>
</div>
<!-- Phnone Number-->

<!-- jee rank-->

<div class="form-group">
<label class="col-md-4 control-label">JEE Main Rank</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input name="rank" id="rank" placeholder="JEE Main Rank" class="form-control" type="text">
</div>
</div>
</div>

<!-- jee rank-->

<div class="form-group">
<label class="col-md-4 control-label">Category</label>
<div class="col-md-4 selectContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-list"></i></span>
<select name="category" id="category" class="form-control selectpicker">
<option value="">Please select your Category</option>
<option value="gen">General</option>
<option value="obc">obc</option>
<option value="sc">SC</option>
<option value="st">ST</option>
</select>
</div>
</div>
</div>

<!-- Address-->

<div class="form-group">
<label class="col-md-4 control-label">Address</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input name="address" id="address" placeholder="Address" class="form-control" type="text">
</div>
</div>
</div>

<!-- Address-->

<!-- City-->
<div class="form-group">
<label class="col-md-4 control-label">City</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input name="city" id="city" placeholder="City" class="form-control" type="text">
</div>
</div>
</div>

<!-- City-->

<!-- Select State -->

<div class="form-group">
<label class="col-md-4 control-label">State</label>
<div class="col-md-4 selectContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-list"></i></span>
<select name="state" id="state" class="form-control selectpicker" >
<option value="">Please select your state</option>
<option>Andhra Pradesh</option>
<option>Arunachal Pradesh</option>
<option >Assam</option>
<option >Bihar</option>
<option >Chattisgarh</option>
<option >Goa</option>
<option >Gujrat</option>
<option >Haryana</option>
<option >Himachal Pradesh</option>
<option> Jammu & Kashmir</option>
<option >Jharkhand</option>
<option >Karnataka</option>
<option >karala</option>
<option >Madhya Pradesh</option>
<option >Meghalaya</option>
<option >Mizoram</option>
<option> Nagaland</option>
<option >Odhisa</option>
<option >Punjab</option>
<option>Rajasthan</option>
<option >Sikkim</option>
<option> TamilNadu</option>
<option >Telanghana</option>
<option >Tripura</option>
<option>Uttarakhand</option>
<option>Uttar Pradesh</option>
<option>West Bengal</option>
</select>
</div>
</div>
</div>

<!-- Select State -->

<!-- Pin Code-->

<div class="form-group">
<label class="col-md-4 control-label">Pin Code</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input name="pin" id="pin" placeholder="Pin Code" class="form-control" type="text">
</div>
</div>
</div>

<!-- Text input-->


<div class="form-group">
<label class="col-md-4 control-label">Date of Birth</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-globe"></i></span>
<input name="dob" id="dob" placeholder="" class="form-control" type="date">
</div>
</div>
</div>

<!-- radio checks -->


<div class="form-group">
<label class="col-md-4 control-label">Gender</label>
<div class="col-md-4">
<div>
<label class="radio-inline">
<input type="radio" name="gender" value="male" /> Male
</label>
<label class="radio-inline">
<input type="radio"
name="gender" value="female" /> Female
</label>
</div>

</div>
</div>

<!-- upload -->


<div class="form-group">
<label class="col-md-4 control-label">Upload Your Profile</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-globe"></i></span>
<input name="photo" id="photo" placeholder="" class="form-control" type="file">
</div>
</div>
</div>

<!-- Success message -->


<div class="alert alert-success" role="alert" id="success_message">Thanks for contacting us, we
will get back to you shortly.</div>

<!-- Button -->


<div class="form-group">
<label class="col-md-4 control-label"></label>
<div class="col-md-4">
<center><button type="submit" class="btn btn-warning" name="apply" id="apply" > Apply
</button></center>
</div>
</div>

</form>
<div style="text-align:center;margin-right:10px;font-size:24px;"><a href="index.php"> Back to
Home </a></div>
</fieldset>
<?php
if (!empty($error)) {
?>
<script>
var error = <?php echo json_encode($error); ?>;
$.each(error, function (key, value) {
$("#" + key).parent(".input-group").parent(".inputGroupContainer").addClass("has-
error").append("<span class='help-block error'>" + value + "</span>")
});
</script>
<?php
}
?>
</div>
<!-- /.container -->

<script src="js/jquery.validate.min.js"></script>
<script src="js/additional-methods.min.js"></script>
<script src="js/jquery.toaster.js"></script>
<script src="js/custom_js.js"></script>
</body>
</html>

Female.php
<?php
include('conn.php');
include('message.php');
$result=mysqli_query($conn,"SELECT * FROM female");
?>
<html>
<head>
<title> Hostel List </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<link rel="stylesheet" href="css/bootstrap.css">


<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/style.css">

<script src="js/jquery-1.11.1.min.js" charset="utf-8"></script>

</head>
<body>
<div class="container well">
<div style="text-align:right;margin-right:10px;font-size:24px;"><a href="index.php"> <u>Back to
Home </u> </a></div>
<center> <h2> Hostel Alloted List (Girl's) </h2> </center> <br> <br>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th> S.NO. </th>
<th> Name </th>
<th> Father's Name </th>
<th> Application Number </th>
<th> Hostel No. </th>
<th> Room No. </th>
</tr>
</thead>
<tbody>
<?php
$i=0;
$cat=array('gen','obc','sc','st');
$seat=array(21,8,8,5);
$count=0;
while($i!=4)
{
$qry="SELECT * FROM female WHERE category='{$cat[$i]}' order by rank
limit 0,{$seat[$i]} ";
$result=mysqli_query($conn,$qry);
if(mysqli_num_rows($result))
{
while($fetch=mysqli_fetch_array($result))
{
$hostel=9;
$room=(int)($count/3)+1;
$count++;
?>
<tr>
<td> <?php echo $count; ?>
</td>
<td>
<?php echo stripslashes($fetch["name"]); ?>
</td>
<td>
<?php echo stripslashes($fetch["fname"]);
?>
</td>
<td>
<?php echo
stripslashes($fetch["application"]); ?>
</td>
<td>
<?php echo $hostel; ?>
</td>
<td>
<?php echo $room; ?>
</td>
</tr>
<?php
}
}
$i++;
}
?>

</tbody>

</table>
<div style="text-align:center;margin-right:100px;font-size:24px;"><a href="index.php"> Back to
Home </a></div>
</div>
</body>
</html>

male.php
<?php
include('conn.php');
include('message.php');
?>
<html>
<head>
<title> Hostel List (Boy's) </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<link rel="stylesheet" href="css/bootstrap.css">


<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/style.css">

<script src="js/jquery-1.11.1.min.js" charset="utf-8"></script>

</head>
<body>
<div class="container well">
<div style="text-align:right;margin-right:10px;font-size:24px;"><a href="index.php"> <u>Back to
Home</u> </a></div>
<center> <h2> Hostel Alloted List (For Boys ) </h2> </center> <br> <br>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th> S.NO. </th>
<th> Name </th>
<th> Father's Name </th>
<th> Application Number </th>
<th> Hostel No. </th>
<th> Room No. </th>
</tr>
</thead>
<tbody>
<?php
$i=0;
$cat=array('gen','obc','sc','st');
$seat=array(59,55,26,20);
$count=0;
while($i!=4)
{
$qry="SELECT * FROM male WHERE category='{$cat[$i]}' order by rank limit
0,{$seat[$i]} ";
$result=mysqli_query($conn,$qry);
if(mysqli_num_rows($result))
{
while($fetch=mysqli_fetch_array($result))
{
if($count<45)
$hostel=7;
else
$hostel=8;
$room=(int)($count/3)+1;
$count++;
?>
<tr>
<td> <?php echo $count; ?>
</td>
<td>
<?php echo stripslashes($fetch["name"]); ?>
</td>
<td>
<?php echo stripslashes($fetch["fname"]);
?>
</td>
<td>
<?php echo
stripslashes($fetch["application"]); ?>
</td>
<td>
<?php echo $hostel;?>
</td>
<td>
<?php echo $room;?>
</td>
</tr>
<?php
}
}
$i++;
}
?>

</tbody>

</table>
<div style="text-align:center;margin-right:100px;font-size:24px;"><a href="index.php"> Back to
Home </a></div>
</div>
</body>
</html>