Cookies on the Xeoncoder.com

We use cookies to ensure that we give you the best experience on our website.
The cookies cannot identify you. If you continue without changing your settings
we'll assume that you are happy to receive all cookies on the Xeoncoder.com website.

The nTeN PTC script code examples will help you to learn how to write your own script features, addons or functions. It's really simple, just check the code examples below.


Check if the user is logged in:

Check if user is logged in or not.

PHP code
if($ZX['AUTH']){
    // user is logged in
} else {
    // user is not logged in
}
Smarty code
{if $ZX['AUTH']}
    user is logged in
{else}
    user is not logged in
{/if}
Update user account profile:

Example of the code that updates user's account profile.

Please note: The MySQL database connection is already open when you use handler GET or POST file!

// check if the user is logged in
if($ZX['AUTH']){

    // try block
    try {

        $pdo->query("
            UPDATE
                `nten_users`
            SET
                # change user password
                `x_password` = SHA1('new password'),

                # change user secondary password
                `x_password_secondary` = SHA1('new secondary password'),

                # enable user secondary password
                `x_password_secondary_status` = '1',

                # change user personal email
                `x_personal` = 'user@example.com'
            WHERE
                `id` = '{$xUS['id']}'
            LIMIT
                1
            ;
        ");

    } catch (PDOException $e) {
        // error: use $e->getMessage() to get more information
    }

} else {
    // error: user is not logged in
}
Suspend user account:

Example of the code that suspends user’s account.

// check if the user is logged in
if($ZX['AUTH']){

    // try block
    try {

        $pdo->query("
            UPDATE
                `nten_users`
            SET
                # suspend account
                `x_suspended` = '1',
                # suspend time
                `x_suspended_time` = UNIX_TIMESTAMP(),
                # suspend reason
                `x_suspended_reason` = 'Some reason'
            WHERE
                `id` = '{$xUS['id']}'
            LIMIT
                1
            ;
        ");

    } catch (PDOException $e) {
        // error: use $e->getMessage() to get more information
    }

} else {
    // error: user is not logged in
}