-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
executable file
·57 lines (45 loc) · 1.59 KB
/
delete.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
<?php
/*
DELETE.PHP
Deletes a specific entry from the the specific table
*/
session_start();
// connect to the database
include('connect_db.php');
// check if the 'id' variable is set in URL, and check that it is valid
if (isset($_GET['id']) && is_numeric($_GET['id'])){
// get id value
$id = $_GET['id'];
// delete the entry
$tablename = $_SESSION['table_type'];
if($tablename == 'basic'){
// if this professor get deleted, delete all the related information!
$query = "SELECT basic.name FROM basic WHERE basic.id = $id";
$result = mysql_query($query)
or die("Counld not process the query: $query". mysql_error());
$row = mysql_fetch_array($result);
if($row){
// delete publication and research area information:
$name = $row[0];
mysql_query("DELETE FROM research WHERE research.name = '$name'")
or die("Could not delete the related research area information !". mysql_error());
mysql_query("DELETE FROM publication WHERE publication.author = '$name'")
or die("Could not delete the related publication information !". mysql_error());
// delete the academic information!
$query = "DELETE FROM academic WHERE academic.id = $id";
mysql_query($query)
or die("Counld not process the query: $query". mysql_error());
}
}
$query = "DELETE FROM $tablename WHERE $tablename.id =$id";
$result = mysql_query($query)
or die("Could not process the query: $query". mysql_error());
// redirect back to the view page
header("Location: users_page.php");
}
else
// if id isn't set, or isn't valid, redirect back to view page
{
header("Location: users_page.php");
}
?>