Skip to content

Commit a1a5f9f

Browse files
committed
9th and Final Commit
1 parent f19b2e0 commit a1a5f9f

14 files changed

+108
-70
lines changed

admin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ function look(x){
5858
function display(x){
5959
$(".rejected , .accepted, .new").hide();
6060
$('.'+x).fadeIn();
61-
}
61+
}

admin_edit.php

+22-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@
33
$regno=isset($_POST['regno_e'])?htmlspecialchars($_POST['regno_e']):0;
44

55
if(isset($_SESSION['alogin']) && htmlspecialchars($_SESSION['alogin'])=='You are logged in,Check Requests'){
6-
$server="localhost";
7-
$username="root";
8-
$password="";
9-
$database="classProject";
10-
11-
$conn=new mysqli($server,$username,$password,$database);
12-
if($conn->connect_error)
13-
die('Fatal Connection error!!');
6+
require 'connection.php';
147
}
158
else{
169
echo '<h1 class="title">You need to Login Again !</h1>';
@@ -26,6 +19,7 @@
2619
<meta charset="utf-8">
2720
<meta name="viewport" content="width=device-width, initial-scale=1">
2821
<link rel="stylesheet" type="text/css" href="admin.css">
22+
<script src="jquery3.3.1.js"></script>
2923
</head>
3024
<body>
3125
<!--Edit Profile-->
@@ -93,7 +87,8 @@
9387
<img class="design" src="img/back2.png">
9488
<h1>&nbsp;&nbsp;&nbsp;&nbsp;Personal Details:</h1>
9589
<h3 class="heading">Date of Birth:&nbsp;<a class=detail>'.$DOB.'</a></h3>
96-
<h3 class="heading"><a class=detail>'.$DOB.'</a></h3>
90+
<input type="hidden" id="dob" value="'.$DOB.'"/>
91+
<h3 class="heading">Age:&nbsp<a class=detail id="age"></a></h3>
9792
<h3 class="heading">Father\'s Name:&nbsp;<a class=detail>'.$fname.'</a></h3>
9893
<h3 class="heading">Mother\'s Name:&nbsp;<a class=detail>'.$mname.'</a></h3>
9994
<h3 class="heading">Guardian\'s email:&nbsp<a class=detail>'.$gemail.'</a></h3>
@@ -111,8 +106,12 @@
111106
<h3 class="heading">12th Standard marks:&nbsp;<a class=detail>'.$m12.'</a></h3>
112107
<h3 class="heading">Extra Curricular<br>Activities:&nbsp;<a class=detail>'.$ECA.'</a></h3>
113108
<h3 class="heading">Scholastic<br>Achievements:&nbsp;<a class=detail>'.$Achievement.'</a></h3>
114-
<h3 class="heading">Hobbies:&nbsp;<br>
109+
</div>
110+
<br>
111+
<div class="content" style="min-height:70vh">
112+
<img class="design" src="img/back2.png">
115113
<img src="img/back2.jpg" class="hobby">
114+
<h3 class="heading">Hobbies:&nbsp;<br>
116115
';
117116
$hobbies=(explode(",",$hobby));
118117
foreach($hobbies as $selected)
@@ -127,5 +126,18 @@
127126
</div>
128127
';
129128
?>
129+
<script>
130+
//age
131+
$(document).ready(function(){
132+
(function(){
133+
var dob=new Date($("#dob").val());
134+
var today= new Date();
135+
var age=today.getFullYear()-dob.getFullYear();
136+
if(today.getMonth() < dob.getMonth() || (today.getMonth()==dob.getMonth() && today.getDate()<dob.getDate()))
137+
age--;
138+
$("#age").text(age);
139+
})();
140+
});
141+
</script>
130142
</body>
131143
</html>

admins.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,7 @@
7474
<!--content-->
7575
<?php
7676
if(isset($_SESSION['alogin']) && htmlspecialchars($_SESSION['alogin'])=='You are logged in,Check Requests'){
77-
$server="localhost";
78-
$username="root";
79-
$password="";
80-
$database="classProject";
81-
82-
$conn=new mysqli($server,$username,$password,$database);
83-
if($conn->connect_error)
84-
die('Fatal Connection error!!');
77+
require 'connection.php';
8578
//New Requests
8679
$sql="SELECT * from students where request=0";
8780
$result=$conn->query($sql);

connection.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
$server="localhost";
3+
$username="root";
4+
$password="";
5+
$database="classProject";
6+
7+
$conn=new mysqli($server,$username,$password,$database);
8+
if($conn->connect_error)
9+
die('Fatal Connection error!!');
10+
?>

img/std_img/20150214.jpg

-107 KB
Loading

index.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
<div id="select">
1919
<div id="student">
2020
<div class="click">
21-
<a target="_blank" href="students"><h1 class="panel" style='float:left;display:inline-block;'>Students' Portal</h1></a>
21+
<a target="_blank" href="students.php"><h1 class="panel" style='float:left;display:inline-block;'>Students' Portal</h1></a>
2222
<img id="std_img" src="img/student.png" style="float:right">
2323
</div>
2424
</div>
2525
<div id="admin">
2626
<div class="click">
2727
<img id ="admin_img" src="img/administrator.png" style="float:left">
28-
<a target="_blank" href="admins"><h1 class="panel" style='float:right;display:inline-block;'>Administrators' Portal</h1></a>
28+
<a target="_blank" href="admins.php"><h1 class="panel" style='float:right;display:inline-block;'>Administrators' Portal</h1></a>
2929
</div>
3030
</div>
3131
</div>

login.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@
1111
header("Location:/classProject",true,303);
1212
}
1313

14-
$server="localhost";
15-
$username="root";
16-
$password="";
17-
$database="classProject";
18-
19-
$conn=new mysqli($server,$username,$password,$database);
20-
if($conn->connect_error)
21-
die('Fatal Connection error!!');
14+
require 'connection.php';
2215

2316
//Login for admins
2417
if($logger=='admins'){

reg.php

+1-9
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@
99
$pass=isset($_POST['password'])?htmlspecialchars($_POST['password']):0;
1010
$request=0;
1111

12-
$servername='localhost';
13-
$username='root';
14-
$password='';
15-
$database='classproject';
16-
17-
$conn = new mysqli($servername,$username,$password,$database);
18-
if($conn->connect_error){
19-
die("Fatal Connection Error !!");
20-
}
12+
require 'connection.php';
2113

2214
if($stmt=$conn->prepare(' insert into students (regno,branch,rollno,name,phone,email,pass,request) values (?,?,?,?,?,?,?,?)')){
2315
$stmt->bind_param("isssissi",$regno,$branch,$rollno,$name,$phone,$email,$pass,$request);

response.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@
44
if($regno==NULL || $response==NULL)
55
header("Location:/classProject",true,303);
66

7-
$server="localhost";
8-
$username="root";
9-
$password="";
10-
$database="classProject";
11-
12-
$conn=new mysqli($server,$username,$password,$database);
13-
if($conn->connect_error)
14-
die('Fatal Connection error!!');
7+
require 'connection.php';
8+
159
$sql="update students set request=".$response." where regno=".$regno;
1610
echo $sql;
1711
$conn->query($sql);

student.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ input,textarea,select{
116116
text-align: center;
117117
display: block;
118118
}
119-
#message1,#message2{
119+
#message,#message1,#message2{
120120
display: none;
121121
font-weight: bold;
122122
border:black solid;

student.js

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Javascript ::
33
*/
4+
//Password checking
45
document.getElementById('password').addEventListener("keyup",function(){
56
var reg = document.getElementById('register_button');
67
var pass = document.getElementById('password');
@@ -64,6 +65,7 @@ function show(x){
6465
$('#'+x).fadeIn();
6566

6667
}
68+
//age
6769
$("input[name ='DOB']").change(function(){
6870
var dob=new Date($(this).val());
6971
var today= new Date();
@@ -81,7 +83,7 @@ $(document).ready(function(){
8183
//banner
8284
$('#login').find('button').attr('disabled','disabled').css('background-color','grey');
8385
$('.banner').fadeTo('slow', 0, function(){
84-
$(this).css({'background-image':'url(img/std_img/'+regno+'.jpg)',
86+
$(this).css({'background-image':'url(img/std_img/'+regno+'.jpg),url(img/banner.jpg)',
8587
'background-size':'cover',
8688
'background-position-x':'0px',
8789
'background-position':'center',
@@ -90,7 +92,7 @@ $(document).ready(function(){
9092
}).fadeTo('slow', 1)
9193
//titles
9294
$('.title2').fadeTo('slow', 0, function(){
93-
$(this).css({'background-image':'url(img/std_img/'+regno+'.jpg)',
95+
$(this).css({'background-image':'url(img/std_img/'+regno+'.jpg),url(img/banner.jpg)',
9496
'background-size':'cover',
9597
'background-position-x':'0px',
9698
'background-position':'center',
@@ -129,7 +131,10 @@ $(document).ready(function(){
129131
alert("Unable to Handle request please try again later !!");
130132
});
131133
});
134+
$("input[name ='DOB']").change();
135+
$("#age").text($("input[name ='age']").val());
132136
});
137+
133138
//Validation
134139

135140
function Validate(x){
@@ -207,4 +212,21 @@ $("#set_button").click(function(){
207212
request.fail(function (jqXHR, textStatus, errorThrown){
208213
alert("Unable to Handle request please try again later !!");
209214
});
210-
});
215+
});
216+
217+
//Image Upload
218+
$('#submit_form').on('submit', function(e){
219+
e.preventDefault();
220+
$.ajax({
221+
url:"upload.php",
222+
method:"POST",
223+
data:new FormData(this),
224+
cache:false,
225+
contentType:false,
226+
processData:false,
227+
success:function(received)
228+
{
229+
$("#message2").html(received);
230+
}
231+
});
232+
});

students.php

+10-13
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,9 @@
124124
<!--content-->
125125
<?php
126126
if(isset($_SESSION['login']) && htmlspecialchars($_SESSION['login'])=='You are logged in,Check Profile'){
127-
$server="localhost";
128-
$username="root";
129-
$password="";
130-
$database="classProject";
131-
132-
$conn=new mysqli($server,$username,$password,$database);
133-
if($conn->connect_error)
134-
die('Fatal Connection error!!');
135-
136127

128+
require 'connection.php';
129+
137130
$sql="SELECT * from students where regno=".$_SESSION['regno'];
138131
$result=$conn->query($sql);
139132
if($result->num_rows > 0) {
@@ -144,8 +137,12 @@
144137
echo'<h1 class="title title2" style="font-size: 1.5em">&nbsp;&nbsp;Profile Picture</h1>
145138
<div class="profile_back" style="background-image: url(img/std_img/'.$_SESSION['regno'].'.jpg),url(img/banner.jpg);">
146139
<div id="profile_name">'.$name.'</div>
147-
<input type="file" name="file" id="file" />
148-
<a class="nav" onclick=$("#file").click()>Upload file</a>
140+
<form method="POST" action="upload.php" id="submit_form" enctype="multipart/form-data">
141+
<input type="file" name="file" id="file" />
142+
<a class="nav" style="bottom:100px;" type=submit onclick=$("#file").click()>Upload file</a>
143+
<input type="submit" id="file_submit"/>
144+
<a class="nav" type=submit onclick=$("#file_submit").click()>Submit Photo</a>
145+
</form>
149146
</div>
150147
<br>';
151148
//Basic Profile
@@ -190,7 +187,7 @@
190187
$hobby=isset($row['hobby'])?htmlspecialchars($row['hobby']):0;
191188
}
192189
else{
193-
$DOB=$fname=$mname=$gemail=$address=$m10=$m12=$ECA=$Achievement=$hobby='';
190+
$DOB=$fname=$mname=$gemail=$address=$m10=$m12=$ECA=$Achievement=$hobby='N/A';
194191
}
195192
echo '<h1 class="title title2" style="font-size: 3em">&nbsp;&nbsp;Additional Details</h1>
196193
<div>
@@ -200,7 +197,7 @@
200197
<h1>&nbsp;&nbsp;&nbsp;&nbsp;Personal Details:</h1>
201198
<form method="POST" id="update_form" action="update.php">
202199
<h3 class="heading">Date of Birth:&nbsp;<input type="date" class="after" name="DOB" placeholder="Enter Date of Birth" value="'.$DOB.'"required disabled ><a class="details before">'.$DOB.'</a></h3>
203-
<h3 class="heading">Age:&nbsp;<input type="number" class="after" name="age" placeholder="Your age here" onload="$(\'input[name =DOB]\').trigger(\'change\');" disabled readonly><a class="details before">'.$DOB.'</a></h3>
200+
<h3 class="heading">Age:&nbsp;<input type="number" class="after" name="age" placeholder="Your age here" disabled readonly><a class="details before" id="age"></a></h3>
204201
<h3 class="heading">Father\'s Name:&nbsp;<input type="text" class="after" name="fname" placeholder="Enter your Father\'s name" value="'.$fname.'" required disabled ><a class="details before">'.$fname.'</a></h3>
205202
<h3 class="heading">Mothers\'s Name:&nbsp;<input type="text" class="after" name="mname" placeholder="Enter your Mother\'s name" value="'.$mname.'" required disabled ><a class="details before">'.$mname.'</a></h3>
206203
<h3 class="heading">Guardian\'s Email Id:&nbsp;<input type="email" class="after" name="gemail" placeholder="Enter email" required value="'.$gemail.'" disabled ><a class="details before">'.$gemail.'</a></h3>

update.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,8 @@
1515
$hobby=implode(",",$_POST['check_list']);
1616
}
1717
if(isset($_SESSION['login']) && htmlspecialchars($_SESSION['login'])=='You are logged in,Check Profile'){
18-
$server="localhost";
19-
$username="root";
20-
$password="";
21-
$database="classProject";
18+
require 'connection.php';
2219

23-
$conn=new mysqli($server,$username,$password,$database);
24-
if($conn->connect_error)
25-
die('Fatal Connection error!!');
2620
}
2721
//Update Table
2822
if($stmt=$conn->prepare('insert into extradetail (regno,DOB,fname,mname,gemail,address,m10,m12,ECA,Achievement,hobby) values (?,?,?,?,?,?,?,?,?,?,?)')){

upload.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
session_start();
3+
if($_FILES['file']['name'] != '')
4+
{
5+
$name=$_FILES['file']['name'];
6+
$name=explode(".", $name);
7+
$extension = end($name);
8+
echo "<script>alert(".$extension.");</script>";
9+
$allowed_type = array("jpg");
10+
if(in_array($extension, $allowed_type))
11+
{
12+
$new_name = $_SESSION['regno'].".". $extension;
13+
$path = "img/std_img/". $new_name;
14+
if(move_uploaded_file($_FILES['file']['tmp_name'], $path))
15+
{
16+
echo "<script>
17+
alert(\"Image Uploaded Sucessfully\");
18+
location.reload(true);
19+
</script>";
20+
}
21+
}
22+
else
23+
{
24+
echo '<script>alert("Invalid File Format,Use \'.jpg\' extension only")</script>';
25+
}
26+
}
27+
else
28+
{
29+
echo '<script>alert("Please Select File")</script>';
30+
}
31+
?>

0 commit comments

Comments
 (0)