/recruitment/profile/unregister_user_exec.php
PHP | 118 lines | 67 code | 25 blank | 26 comment | 15 complexity | 7e17acd78c689859c24a2756e5d4e1fe MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- require_once('../helper_functions.php');
- require_once('../../lib/database.php');
- openConnection();
-
- if (!isset($_SESSION)) {
- session_start();
- }
- //remember to check for illegal access
- if(!isset($_SESSION['msgDetails'])){
- $_SESSION['msgCaption'] = '';
- $_SESSION['msgDetails'] = '';
- }
-
- $redirectToURL = 'profile.php';
-
- if( isset($_POST['btnDelete']) || isset($_POST['btnCancel'])){
- if (isset($_POST['btnCancel'])){
- header("location: $redirectToURL");
- exit();
- }else if (isset($_POST['btnDelete'])) {
-
- $user_id = $_SESSION['user_account_row_id'];
-
- //delete user response details first:
- $q = "DELETE FROM tbladvertresponses WHERE applicantid = $user_id";
- $query = mysql_query($q);
-
- //delete user response details first:
- // $q = "DELETE FROM tblapplicantscvs WHERE appaccountrowid = $user_id";
- // $query = mysql_query($q);
-
- //delete user response details first:
- // $q = "DELETE FROM tblapplicantscvsprofquals WHERE appaccountrowid = $user_id";
- // $query = mysql_query($q);
-
- //delete user response details first:
- // $q = "DELETE FROM tblapplicantscvsworkexp WHERE appaccountrowid = $user_id";
- // $query = mysql_query($q);
-
-
- //delete user response details first:
- // $q = "DELETE FROM tblapplicantsreferees WHERE appaccountrowid = $user_id";
- // $query = mysql_query($q);
-
- //delete user response details first:
- $q = "DELETE FROM tblapplicantscontacts WHERE appaccountrowid = $user_id";
- $query = mysql_query($q);
-
-
- //take out their passport, if it exists:
- $q = "SELECT profile_pic FROM tblapplicantsdetails WHERE appaccountrowid = $user_id";
-
- $query = mysql_query($q);
- $loginFoundUser = mysql_num_rows($query);
-
- if ($loginFoundUser == 1) {
- $row = mysql_fetch_assoc($query);
- if (isset($row['profile_pic']) && strlen($row['profile_pic']) == 16){
- $file_to_delete = $row['profile_pic'] . '.jpg';
- // if(file_exists("$filename"))
- //fclose($fp);
- chdir('profilepics/');
- $r = unlink($file_to_delete);
- if($r == "1"){
- //echo "The passport was deleted successfully.";
- } else {
- //echo "There was an error trying to delete the passport.";
- }
- }
- }
-
- //delete user response details first:
- $q = "DELETE FROM tblapplicantsdetails WHERE appaccountrowid = $user_id";
- $query = mysql_query($q);
-
- //delete user response details first:
- $q = "DELETE FROM tblapplicantshighestqual WHERE appaccountrowid = $user_id";
- $query = mysql_query($q);
-
- //delete user response details first:
- $q = "DELETE FROM tblapplicantsotherphones WHERE appaccountrowid = $user_id";
- $query = mysql_query($q);
-
- //delete user response details first:
- $q = "DELETE FROM tblapplicantsprofqualifications WHERE appaccountrowid = $user_id";
- $query = mysql_query($q);
-
- //delete user response details first:
- $q = "DELETE FROM tblapplicantsworkexperience WHERE appaccountrowid = $user_id";
- $query = mysql_query($q);
-
- //then delete the user:
- $q = "DELETE FROM tblapplicantsaccount WHERE account_rowid = $user_id";
- $query = mysql_query($q);
-
-
- if(mysql_affected_rows() > 0){
- $_SESSION['user_account_row_id'] = 0;
- $redirectToURL = '../index.php';
- $c = 'OK';
- $e = 'The user account was successfully deleted on the server.';
- }else{
- $c = 'Error';
- $e = 'There was an error while deleting the user account on the server.';
- }
-
- $_SESSION['msgCaption'] = $c;
- $_SESSION['msgDetails'] = $e;
- }//end if (isset($_POST['btnCancel']))
- }else{
- include_once('../access_error.php');
- $redirectToURL = '../';
- }//end if( isset($_POST['btnSave']) || isset($_POST['btnCancel']) )
-
- header("location: $redirectToURL");
- exit();
- ?>