PageRenderTime 73ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/recruitment/profile/unregister_user_exec.php

https://bitbucket.org/lecturer34/hrmis
PHP | 118 lines | 67 code | 25 blank | 26 comment | 15 complexity | 7e17acd78c689859c24a2756e5d4e1fe MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. require_once('../helper_functions.php');
  3. require_once('../../lib/database.php');
  4. openConnection();
  5. if (!isset($_SESSION)) {
  6. session_start();
  7. }
  8. //remember to check for illegal access
  9. if(!isset($_SESSION['msgDetails'])){
  10. $_SESSION['msgCaption'] = '';
  11. $_SESSION['msgDetails'] = '';
  12. }
  13. $redirectToURL = 'profile.php';
  14. if( isset($_POST['btnDelete']) || isset($_POST['btnCancel'])){
  15. if (isset($_POST['btnCancel'])){
  16. header("location: $redirectToURL");
  17. exit();
  18. }else if (isset($_POST['btnDelete'])) {
  19. $user_id = $_SESSION['user_account_row_id'];
  20. //delete user response details first:
  21. $q = "DELETE FROM tbladvertresponses WHERE applicantid = $user_id";
  22. $query = mysql_query($q);
  23. //delete user response details first:
  24. // $q = "DELETE FROM tblapplicantscvs WHERE appaccountrowid = $user_id";
  25. // $query = mysql_query($q);
  26. //delete user response details first:
  27. // $q = "DELETE FROM tblapplicantscvsprofquals WHERE appaccountrowid = $user_id";
  28. // $query = mysql_query($q);
  29. //delete user response details first:
  30. // $q = "DELETE FROM tblapplicantscvsworkexp WHERE appaccountrowid = $user_id";
  31. // $query = mysql_query($q);
  32. //delete user response details first:
  33. // $q = "DELETE FROM tblapplicantsreferees WHERE appaccountrowid = $user_id";
  34. // $query = mysql_query($q);
  35. //delete user response details first:
  36. $q = "DELETE FROM tblapplicantscontacts WHERE appaccountrowid = $user_id";
  37. $query = mysql_query($q);
  38. //take out their passport, if it exists:
  39. $q = "SELECT profile_pic FROM tblapplicantsdetails WHERE appaccountrowid = $user_id";
  40. $query = mysql_query($q);
  41. $loginFoundUser = mysql_num_rows($query);
  42. if ($loginFoundUser == 1) {
  43. $row = mysql_fetch_assoc($query);
  44. if (isset($row['profile_pic']) && strlen($row['profile_pic']) == 16){
  45. $file_to_delete = $row['profile_pic'] . '.jpg';
  46. // if(file_exists("$filename"))
  47. //fclose($fp);
  48. chdir('profilepics/');
  49. $r = unlink($file_to_delete);
  50. if($r == "1"){
  51. //echo "The passport was deleted successfully.";
  52. } else {
  53. //echo "There was an error trying to delete the passport.";
  54. }
  55. }
  56. }
  57. //delete user response details first:
  58. $q = "DELETE FROM tblapplicantsdetails WHERE appaccountrowid = $user_id";
  59. $query = mysql_query($q);
  60. //delete user response details first:
  61. $q = "DELETE FROM tblapplicantshighestqual WHERE appaccountrowid = $user_id";
  62. $query = mysql_query($q);
  63. //delete user response details first:
  64. $q = "DELETE FROM tblapplicantsotherphones WHERE appaccountrowid = $user_id";
  65. $query = mysql_query($q);
  66. //delete user response details first:
  67. $q = "DELETE FROM tblapplicantsprofqualifications WHERE appaccountrowid = $user_id";
  68. $query = mysql_query($q);
  69. //delete user response details first:
  70. $q = "DELETE FROM tblapplicantsworkexperience WHERE appaccountrowid = $user_id";
  71. $query = mysql_query($q);
  72. //then delete the user:
  73. $q = "DELETE FROM tblapplicantsaccount WHERE account_rowid = $user_id";
  74. $query = mysql_query($q);
  75. if(mysql_affected_rows() > 0){
  76. $_SESSION['user_account_row_id'] = 0;
  77. $redirectToURL = '../index.php';
  78. $c = 'OK';
  79. $e = 'The user account was successfully deleted on the server.';
  80. }else{
  81. $c = 'Error';
  82. $e = 'There was an error while deleting the user account on the server.';
  83. }
  84. $_SESSION['msgCaption'] = $c;
  85. $_SESSION['msgDetails'] = $e;
  86. }//end if (isset($_POST['btnCancel']))
  87. }else{
  88. include_once('../access_error.php');
  89. $redirectToURL = '../';
  90. }//end if( isset($_POST['btnSave']) || isset($_POST['btnCancel']) )
  91. header("location: $redirectToURL");
  92. exit();
  93. ?>