-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudentdash.php
160 lines (140 loc) · 5.87 KB
/
studentdash.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
include 'dbconfig.php';
session_start();
$user_id = $_SESSION['user_id'];
//insert acdmic data
if (isset($_POST['form2-save'])) {
$roll = mysqli_real_escape_string($conn, $_POST['rollno']);
$age = mysqli_real_escape_string($conn, $_POST['age']);
$sem = mysqli_real_escape_string($conn, $_POST['semester']);
$check_user = mysqli_query($conn, "SELECT * FROM `academic_info` WHERE student_id = '$user_id'") or die('failed to serch');
if (mysqli_num_rows($check_user) > 0) {
$update_acd = mysqli_query($conn, "UPDATE `academic_info` SET `rno`='$roll',`age`='$age',`sem`='$sem' WHERE student_id='$user_id'");
if ($update_acd) {
echo "<script>
alert('academic information updated successfully');
window.location.href='studentdashborad.php';
</script>";
} else {
echo "<script>
alert('failed to update data');
window.location.href='studentdashborad.php';
</script>";
}
} else {
$insert_acd = mysqli_query($conn, "INSERT INTO `academic_info`(`rno`,`age`, `sem`, `student_id`) VALUES ('$roll','$age','$sem','$user_id')") or die('query failed');
if ($insert_acd) {
echo "<script>
alert('academic information inserted successfully');
window.location.href='studentdashborad.php';
</script>";
} else {
echo "<script>
alert('failed to insert data');
window.location.href='studentdashborad.php';
</script>";
}
}
}
//insert student data
if (isset($_POST['placement_save'])) {
$stuname = $fetch['fname'];
$phone = $fetch['phoneno'];
$email = $fetch['email'];
$username = $fetch['uname'];
$skill = mysqli_real_escape_string($conn, $_POST['skill']);
$loc = mysqli_real_escape_string($conn, $_POST['location']);
$link = mysqli_real_escape_string($conn, $_POST['link']);
$about = mysqli_real_escape_string($conn, $_POST['about']);
$image = $_FILES['image']['name'];
$image_size = $_FILES['image']['size'];
$image_tmp_name = $_FILES['image']['tmp_name'];
$image_folder = 'Studentimg/' . $image;
$resume = $_FILES['resume']['name'];
$resume_size = $_FILES['resume']['size'];
$resume_tmp_name = $_FILES['resume']['tmp_name'];
$resume_folder = 'resume/' . $resume;
$select = mysqli_query($conn, "SELECT * FROM `placement` WHERE student_id = '$user_id'") or die('query failed');
if (mysqli_num_rows($select) > 0) {
echo "<script>
alert('you already inserted data');
window.location.href='studentdashborad.php';
</script>";
} else {
if ($image_size > 2000000) {
echo "<script>
alert('image is too large');
window.location.href='studentdashborad.php';
</script>";
} else {
$insert_placement = mysqli_query($conn, "INSERT INTO `placement`(`skill`, `location`, `linkdin`, `about`,`profile`,`resume`,`student_id`)
VALUES ('$skill','$loc','$link','$about','$image','$resume','$user_id')") or die('query2 failed');
$update_placement = mysqli_query($conn, "UPDATE `placement` SET `skill`='$skill',`location`='$loc',`linkdin`='$link',`about`='$about',`profile`='$image',`resume`='$resume' WHERE student_id='$user_id'") or die('query3 failed');
if ($update_placement) {
move_uploaded_file($image_tmp_name, $image_folder);
move_uploaded_file($resume_tmp_name, $resume_folder);
echo "<script>
alert('placement information inserted successfully');
window.location.href='studentdashborad.php';
</script>";
} else {
echo "<script>
alert('failed to insert information');
window.location.href='studentdashborad.php';
</script>";
}
}
}
}
//update placement data
if (isset($_POST['placement_update'])) {
$skill = mysqli_real_escape_string($conn, $_POST['skill']);
$loc = mysqli_real_escape_string($conn, $_POST['location']);
$link = mysqli_real_escape_string($conn, $_POST['link']);
$about = mysqli_real_escape_string($conn, $_POST['about']);
$update_placement = mysqli_query($conn, "UPDATE `placement` SET `skill`='$skill',`location`='$loc',`linkdin`='$link',`about`='$about' WHERE student_id='$user_id'") or die('update failed');
if ($update_placement) {
echo "<script>
alert('placement information updated successfully');
window.location.href='studentdashborad.php';
</script>";
} else {
echo "<script>
alert('failed to update information');
window.location.href='studentdashborad.php';
</script>";
}
// update image
$update_image = $_FILES['image']['name'];
$update_image_size = $_FILES['image']['size'];
$update_image_tmp_name = $_FILES['image']['tmp_name'];
$update_image_folder = 'Studentimg/'.$update_image;
if (!empty($update_image)) {
if ($update_image_size > 4000000) {
echo "<script>
alert('profile image to large');
window.location.href='studentdashborad.php';
</script>";
} else {
$image_update_query = mysqli_query($conn, "UPDATE `placement` SET profile = '$update_image' WHERE student_id = '$user_id'") or die('query failed');
if ($image_update_query) {
move_uploaded_file($update_image_tmp_name, $update_image_folder);
}
echo "<script>
alert('profile image updated successfully');
window.location.href='studentdashborad.php';
</script>";
}
}
//update resume
$update_resume = $_FILES['resume']['name'];
$update_resume_size = $_FILES['resume']['size'];
$update_resume_tmp_name = $_FILES['resume']['tmp_name'];
$update_resume_folder = 'resume/' . $update_resume;
if (!empty($update_resume)) {
$resume_update_query = mysqli_query($conn, "UPDATE `placement` SET resume = '$update_resume' WHERE student_id = '$user_id'") or die('query failed');
if ($resume_update_query) {
move_uploaded_file($update_resume_tmp_name, $update_resume_folder);
}
}
}