-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_stack.php
40 lines (32 loc) · 1.18 KB
/
delete_stack.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
<?php
session_start();
$userID = $_SESSION['userid'];
if( ! isset( $_SESSION['username'] ) )
{
header( "Location: error.php?error=2" );
exit;
}
$stackid = $_GET['id'];
include('mysql_connect.php');
if( mysql_num_rows(mysql_query("SELECT * FROM `stacks` where `users_id` =$userID AND `id` =$stackid")) != 1 )
{
echo "You do not have permission to delete this stack.";
}
mysql_query("DELETE FROM `stacks` WHERE `id` =$stackid");
mysql_query("DELETE FROM `cards` WHERE `stacks_id` =$stackid");
mysql_query("DELETE FROM `parts` WHERE `stacks_id` =$stackid");
$query = mysql_query("SELECT * FROM stacks WHERE id='$stackid'");
$numrowsStacks = mysql_num_rows($query);
$query = mysql_query("SELECT * FROM cards WHERE stacks_id='$stackid'");
$numrowsCards = mysql_num_rows($query);
$query = mysql_query("SELECT * FROM parts WHERE stacks_id='$stackid'");
$numrowsParts = mysql_num_rows($query);
if ( $numrowsStacks == 0 || $numrowsCards == 0 || $numrowsParts == 0 )
{
header('Location: stack.php?stack=1');
}
else
{
echo "There has been an error, and your stack was not deleted. Please try again.</br>If this error persists, please contect <a href='mailto:[email protected]'>[email protected]</a>.";
}
?>