-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteStudent.php
More file actions
110 lines (97 loc) · 3.22 KB
/
deleteStudent.php
File metadata and controls
110 lines (97 loc) · 3.22 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Delete Student</title>
<link rel="stylesheet" type="text/css" href="login.css">
</head>
<body>
<div class="Menu">
<ul>
<li><a class="active" href="process.php">Home</a></li>
<li><a href="insert.php">Insert</a></li>
<li><a href="update.php">Update</a></li>
<li><a href="delete.php">Delete</a></li>
<li><a href="peek.php">Peek</a></li>
</ul>
</div>
<div class="loginbox" style="top: 400px; height: 570px; width: 400px;">
<img src="p2.png" class="avatar">
<form action="#" method="POST">
<p>Enter the <strong>id</strong> of the Student you want to <strong style="color: pink">delete</strong>.</p>
<input type="text" name="Tid" placeholder="0">
<p>Re-enter the <strong>id</strong> of the Student you want to <strong style="color: pink">delete.</strong></p>
<input type="text" name="RTid" placeholder="0">
<br>
<p>Type "yes" if you want to delete the Student details. <strong style="color: pink">NOTE: THIS ACTION CANNOT BE UNDONE.</strong></p>
<input type="text" name="agree" placeholder="No">
<br><br>
<p>Enter password</p>
<input type="password" name="pass">
<br><br>
<input type="submit" name="submit" value="DELETE">
</form>
</div>
<div class = "logout">
<a href="login.php">
<img src="p3.png" alt="Logout" style="width:50px;height:42px;border:0;position: fixed;top: 8px;right: 16px;font-size: 18px;">
</a>
</div>
</body>
</html>
<?php
$host = "localhost";
$user="root";
$password="";
$db="Hogwarts";
$con=mysqli_connect("localhost","root","","Hogwarts");
if($con === false)
{
echo "Connection failed to establish";
}
mysqli_select_db($con,$db);
if(isset($_POST['Tid']) && isset($_POST['RTid']) && isset($_POST['agree']) && isset($_POST['pass']))
{
$Tid=$_POST['Tid'];
$RTid=$_POST['RTid'];
$agree=$_POST['agree'];
$pass=$_POST['pass'];
$sql = "select * from Hogwarts.login where uname='admin' AND pass='".$pass."' limit 1";
$result=mysqli_query($con,$sql);
if (mysqli_num_rows($result)==1)
{
if($Tid == $RTid)
{
if($agree=="Yes" || $agree =="yes")
{
$sql = "DELETE from Student WHERE id = '$Tid'";
$result = mysqli_query($con,$sql);
if($result)
{
?> <div style= "width:50px;height:42px;border:0;position: fixed;top: 20%; left: 3%;font-size: 18px;">
<font color="white"><?php echo "Record deleted successfully";?></font></div><?php
}
else
{
?> <div style= "width:50px;height:42px;border:0;position: fixed;top: 20%; left: 3%;font-size: 18px;">
<font color="white"><?php echo "Record not found";?></font></div><?php
}
}
else
{
?> <div style= "width:50px;height:42px;border:0;position: fixed;top: 20%; left: 3%;font-size: 18px;">
<font color="white"><?php echo "Record not deleted";?></font></div><?php
}
}
else
{
?> <div style= "width:50px;height:42px;border:0;position: fixed;top: 20%; left: 3%;font-size: 18px;">
<font color="white"><?php echo "Teacher ids not matching";?></font></div><?php
}
}
else
{
?> <div style= "width:50px;height:42px;border:0;position: fixed;top: 20%; left: 3%;font-size: 18px;">
<font color="white"><?php echo "Password incorrect. Record not deleted";?></font></div><?php
}
}
?>