-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathupdt-res-form.php
208 lines (192 loc) · 5.35 KB
/
updt-res-form.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html>
<head>
<title>update result</title>
<link rel="stylesheet" type="text/css" href="css/updt-res-form.css">
</head>
<body style="color: #B739FE">
<div>
<form action="#" method="post" ><br>
<h2> UPDATE FORM</h2>
<br><br>
<font color="#0303AC">
Enter Roll Number to UPDATE
</font>
<input class="input-box" type="VALUE" name="rollno" placeholder="ROLL NUMBER"><br>
<button class="button" type="submit" name="Submit" style="vertical-align:middle; margin-top: 10px">
<span>Submit </span>
</button>
</form>
</div>
</body>
</html>
<?php
if (isset($_POST['update'])) {
$con=mysqli_connect('localhost','root','','rms');
if (!$con) {
die("Connection failed");
}
$sql="SELECT * FROM result";
$res=mysqli_query($con,$sql);
$row = mysqli_fetch_array($res);
//student details
$uname = $_POST['cng-name'];
$uroll = $_POST['cng-roll'];
$ufname = $_POST['cng-fname'];
$udob = $_POST['cng-dob'];
$ucont = $_POST['cng-cont'];
//image
$uimg_name = $_FILES['f1']['name'];
//marks details
$umaths = $_POST['cng-math'];
$ueng = $_POST['cng-eng'];
$uphy = $_POST['cng-phy'];
$udsa = $_POST['cng-dsa'];
$ube = $_POST['cng-be'];
$sqli = "UPDATE `result` SET `name` = '$uname', `roll`= '$uroll', `fname`='$ufname', `dob`='$udob', `contact`='$ucont', `imgpath`='$uimg_name', `maths`='$umaths', `english`='$ueng', `phy`='$uphy', `dsa`='$udsa', `be`='$ube' WHERE roll = $uroll";
$chk = mysqli_query($con , $sqli);
if($chk)
echo "<script>alert(DATA UPDATED)</script>";
else
echo "<script>alert(DATA UPDATE FAILED)</script>";
// $sql = "INSERT INTO `user_image`(`img_path`) VALUES(')";
$move = move_uploaded_file($_FILES['f1']['tmp_name'], 'up/'.$uname);
if ($move){
echo "<script>alert(file uploaded)</script>";
}
else
echo "<script>alert(failed)</script>";
}
if (isset($_POST['Submit'])) {
// echo"hello hello mic testing 123 chk chk";
$con=mysqli_connect('localhost','root','','rms');
if (!$con) {
die("Connection failed");
}
else{
$roll =$_POST['rollno'];
$sql = "SELECT * FROM result";
$res = mysqli_query($con,$sql);
$num_rows=mysqli_num_rows($res);
if($num_rows>0){
while($row=mysqli_fetch_array($res)){
if($roll == $row['roll']){
$sql="SELECT * FROM result";
$res=mysqli_query($con,$sql);
$num_rows=mysqli_num_rows($res);
while($row=mysqli_fetch_array($res))
{
if($roll == $row['roll']){
$name = $row['name'];
$rollno = $row['roll'];
$faname = $row['fname'];
$contact = $row['contact'];
$dob = $row['dob'];
if($row['imgpath']) $imgname = $row['imgpath'];
else $imgname="no";
$math = $row['maths'];
$eng = $row['english'];
$phy = $row['phy'];
$dsa = $row['dsa'];
$be = $row['be'];
}
}
echo '
<hr>
<div >
<br>
<form action="#" method="POST" enctype="multipart/form-data">
<table>
<th><br>
<tr> STUDENTS DETAILS:--</tr>
<br>
</th>
<th>
<tr>NAME</tr>
<tr><input class="input-box" type="text" name="cng-name" value='; echo $name; echo'>
</th>
<br><br>
<th>
<tr>ROLL</tr>
<tr><input class="input-box" type="text" name="cng-roll" value='; echo $rollno; echo'>
</th>
<br><br>
<th>
<tr>FATHER\'s NAME</tr>
<tr><input class="input-box" type="text" name="cng-fname" value='; echo $faname; echo'>
</th>
<br><br>
<th>
<tr>CONTACT</tr>
<tr><input class="input-box" type="number" name="cng-cont" value='; echo $contact; echo'>
</th>
<br><br>
<th>
<tr>DATE OF BIRTH</tr>
<tr><input class="input-box" type="date" name="cng-dob" value='; echo $dob; echo'>
</th>
<br><br>
<th>
<tr>IMAGE</tr>
';
if(!$imgname) echo "NO IMAGE FOUND IN DATA BASE!!";
else echo "<img src='up/$imgname'>";
echo'
</th>
<br><br>
<th>
<tr align="right">Photo</tr>
<tr><input type="file" name="f1"></tr>
</tr>
</table>
<table>
<th><br>
<tr> MARKS DETAILS:--</tr>
<br>
</th>
<br>
<th>
<tr>MATHS</tr>
<tr><input class="input-box" type="text" name="cng-math" value='; echo $math; echo'>
</th>
<br><br>
<th>
<tr>ENGLISH</tr>
<tr><input class="input-box" type="text" name="cng-eng" value='; echo $eng; echo'>
</th>
<br><br>
<th>
<tr>PHYSICS</tr>
<tr><input class="input-box" type="text" name="cng-phy" value='; echo $phy; echo'>
</th>
<br><br>
<th>
<tr>DSA</tr>
<tr><input class="input-box" type="text" name="cng-dsa" value='; echo $dsa; echo'>
</th>
<br><br>
<th>
<tr>BE</tr>
<tr><input class="input-box" type="text" name="cng-be" value='; echo $be; echo'>
</th>
</table>
<div>
<button class="button" type="submit" name="update" value="update" style="vertical-align:middle; margin-top: 10px">
<span>UPDATE</span>
</button>
</div>
</form>
</div>
';
$msg = "";
break;
}
else{
$msg= "ROLL NUMBER NOT FOUND!!";
}
}
if($roll != $row['roll']) echo "$msg";
}
}
}
?>