PageRenderTime 26ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/sandbox/deleteorganization2.php

http://ndepics-redcross.googlecode.com/
PHP | 72 lines | 50 code | 9 blank | 13 comment | 13 complexity | e8938542c00ebbd12538eb31125dc861 MD5 | raw file
  1. <?php
  2. //****************************
  3. // Developed by Notre Dame EPICS for St. Joe County RedCross
  4. // Fall 2008 - Mike Ellerhorst & Mark Pasquier
  5. // Summer 2010 - Matt Mooney
  6. // deleteorganization2.php - Page to delete organization from database
  7. //****************************
  8. session_start(); //resumes active session
  9. if(($_SESSION['valid']) != "valid") { //check for credentials
  10. header( 'Location: ./index.php' ); //redirect to index if not logged in
  11. }
  12. if( ($_SESSION['access_level_id'] != 2) && ($_SESSION['access_level_id'] != 3) && ($_SESSION['access_level_id'] != 6) && ($_SESSION['access_level_id'] != 7) && ($_SESSION['access_level_id'] != 9)) { //ensure user has delete rights
  13. header( 'Location: ./index.php' ); //redirect if not authorized
  14. }
  15. include ("config/dbconfig.php"); //database name and password
  16. include ("config/opendb.php"); //open connection to database
  17. include("config/functions.php"); //imports external functions
  18. include("html_include_1.php"); //open HTML tags
  19. echo "<title>St. Joseph Red Cross - Delete Organization</title>"; //print page title
  20. include("html_include_2.php"); //rest of HTML header information
  21. echo "<h1>Delete Organization</h1>";
  22. //Pick up the POSTed organization_id
  23. $organization_id = $_POST['organization_id'];
  24. //MAIN DELETE QUERY: Delete organization from organization table
  25. $query = "DELETE
  26. FROM organization
  27. WHERE organization_id = ".$organization_id."
  28. LIMIT 1";
  29. $result = mysql_query($query) or die ("Deletion Query failed (organization)");
  30. //Delete works_for relationships to persons
  31. $query = "DELETE
  32. FROM works_for
  33. WHERE organization_id = ".$organization_id;
  34. $result = mysql_query($query) or die ("Deletion Query 2 failed (works_for)");
  35. //Delete resource_listing relationships to resources
  36. $query = "DELETE
  37. FROM resource_listing
  38. WHERE organization_id = ".$organization_id;
  39. $result = mysql_query($query) or die ("Deletion Query 3 failed (resrouce_listing)");
  40. //Delete Statement of Understanding files
  41. $query = "DELETE
  42. FROM statement_of_understanding
  43. WHERE organization_id = ".$organization_id;
  44. $result = mysql_query($query) or die ("Deletion Query 4 failed (SoU)");
  45. //Delete Facility Survey files
  46. $query = "DELETE
  47. FROM facility_survey
  48. WHERE organization_id = ".$organization_id;
  49. $result = mysql_query($query) or die ("Deletion Query 5 failed (facility_survey) IGNORE THIS");
  50. //Delete shelter_info listing
  51. $query = "DELETE
  52. FROM shelter_info
  53. WHERE organization_id = ".$organization_id;
  54. $result = mysql_query($query) or die ("Deletion Query 6 failed (shelter_info): Ignore if not shelter");
  55. print "<center><h2>Organization Deleted Successfully</h2></center>";
  56. print "<div align='center'>";
  57. print "<form action=\"./home.php\">\n";
  58. print "<button type=\"submit\">Return Home</button>";
  59. print "</form>\n";
  60. print "</div><br />";
  61. include ("config/closedb.php"); //close connection to database
  62. include("html_include_3.php"); //close HTML tags
  63. ?>