This script handles the deletion of the user account initiated by the user himself. More...
Functions | |
| terminateAccountDeleteWithError ($errorParam) | |
Variables | |
| $user_id = $_SESSION['user_id'] | |
| if(isset($error) && $error==="db_access_failed") | try |
| $userExists = $stmt->fetchColumn() | |
| if(! $userExists) | $stmt = $pdo->prepare("DELETE FROM users WHERE id = :user_id") |
| catch(PDOException $e) | $_SESSION = [] |
This script handles the deletion of the user account initiated by the user himself.
Connects to the database, checks if the user with id of the one set in $_SESSION['user_id'] exists in 'users' table of the database, deletes the record if true. Terminates and redirects to the main page in case of error with error context provided as a parameter of the redirecting GET request.
| terminateAccountDeleteWithError | ( | $errorParam | ) |
Redirects to the index page with a specified error parameter and terminates the script.
| string | $errorParam | The error parameter to be appended to the URL. |
| catch (PDOException $e) $_SESSION = [] |
| if (! $userExists) $stmt = $pdo->prepare("DELETE FROM users WHERE id = :user_id") |
| $user_id = $_SESSION['user_id'] |
| $userExists = $stmt->fetchColumn() |
| try |
Check if there was a database access error and terminate the account deletion process if so.