-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete_student.php
86 lines (50 loc) · 1.55 KB
/
delete_student.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
<?php
/*
delete_student.php
Deletes a specific entry from the 'players' table
*/
// connect to the database
include('config.php');
$confirm_msg ="Confirm Delete ";
echo ' <script> alert("'.'$confirm_msg'.'") </script> ';
echo ' <script> alert("'.'DELETED!!!!!!!'.'") </script> ';
// check if the 'anumber' variable is set in URL, and check that it is valid
if (isset($_GET['anumber']) && isset($_GET['confirm']))
{
// get anumber value
$anumber = $_GET['anumber'];
$confirm = $_GET['confirm'];
$confirm_msg ="Confirm Delete ";
echo ' <script> alert("'.$confirm_msg.'") </script> ';
if($confirm== 0){
// delete the entry
if(mysqli_query($link, "DELETE FROM students WHERE anumber='$anumber'")){
echo ' <script> alert("'.'DELETED!!!!!!!'.'") </script> ';
$confirm = 1;
if ($confirm==1){
echo ' <script> alert("'.'DELETED!!!!!!!'.'") </script> ';
header("Location: view_all_students.php?sort=all");
}
}
else{
echo "Error: ".mysqli_error($link);
}
}
// delete the entry
// $result = mysqli_query($connection, "DELETE FROM players WHERE anumber=$anumber");
// or die(mysql_error());
if ($confirm==1){
echo ' <script> alert("'.'DELETED!!!!!!!'.'") </script> ';
header("Location: view_all_students.php?sort=all");
}
// redirect back to the view page
// else{
// header("Location: view_all_students.php");
// }
}
else
// if anumber isn't set, or isn't valid, redirect back to view page
{
echo "Failed";
}
?>