AutoPulse v 1.0.1
 
Loading...
Searching...
No Matches
C:/Users/ivans/OneDrive/Документы/ZWA/sem/process-accountDelete.php File Reference

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 = []
 

Detailed Description

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.

Function Documentation

◆ terminateAccountDeleteWithError()

terminateAccountDeleteWithError ( $errorParam)

Redirects to the index page with a specified error parameter and terminates the script.

Parameters
string$errorParamThe error parameter to be appended to the URL.

Variable Documentation

◆ $_SESSION

catch (PDOException $e) $_SESSION = []

◆ $stmt

if (! $userExists) $stmt = $pdo->prepare("DELETE FROM users WHERE id = :user_id")

◆ $user_id

$user_id = $_SESSION['user_id']

◆ $userExists

$userExists = $stmt->fetchColumn()

◆ try

try
Initial value:
{
$stmt = $pdo->prepare("SELECT COUNT(*) FROM users WHERE id = :user_id")
if(! $user) catch(PDOException $e) $pdo
Definition myprofile.php:59
if(! $userExists) $stmt
Definition process-accountDelete.php:48

Check if there was a database access error and terminate the account deletion process if so.