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

This scripts handles displaying user his profile with some account managing interface. More...

Functions

 terminateProfileWithError ($errorParam)
 Redirects to the index page with an error parameter.
 

Variables

if(isset($error) && $error==="db_access_failed") try
 
 $user = $stmt->fetch(PDO::FETCH_ASSOC)
 
if(! $user) catch(PDOException $e) $pdo = null
 
 $editdata_params = []
 Parameters for profile editing, initialized based on the user type.
 
if( $user[ 'person_type']==='private') elseif ( $user[ 'person_type']==='company')
 
 endif
 

Detailed Description

This scripts handles displaying user his profile with some account managing interface.

Checks if the $_SESSION['user_id'] is set as this functionality is only available to the authorized users. Connects to the database. Checks if there exists a record with id equal to the one set in $_SESSION['user_id']. If true, retrieves the whole user record from the 'users' table of the database and displays them. User first_name and last_name are displayed for the users of type 'private'. User 'company_name' is displayed for the users of type 'company' instead. Displays buttons that enable users to edit their account data or delete their account. For the users of type 'private', there's also a button that enables to make a request for admin rights, which is active and clickable, if the value of 'admin_requested' column for the current user is false. 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

◆ terminateProfileWithError()

terminateProfileWithError ( $errorParam)

Redirects to the index page with an error parameter.

Parameters
string$errorParamThe error parameter to append to the URL.

Variable Documentation

◆ $editdata_params

$editdata_params = []

Parameters for profile editing, initialized based on the user type.

◆ $pdo

if(! $user) catch (PDOException $e) $pdo = null

◆ $user

$user = $stmt->fetch(PDO::FETCH_ASSOC)

◆ elseif

if($user['person_type']==='private') elseif($user['person_type']==='company') ( $user[ 'person_type'] = == 'company')

◆ endif

endif

◆ try

if (isset( $error) &&$error==="db_access_failed") try
Initial value:
{
$stmt = $pdo->prepare("SELECT person_type, first_name, last_name, company_name, email, admin_requested FROM users WHERE id = :id")
if(! $user) catch(PDOException $e) $pdo
Definition myprofile.php:59
if(! $userExists) $stmt
Definition process-accountDelete.php:48