Location: PHPKode > projects > Scriptorium > scriptorium1.6/user_management/confirm_account.php
<?php

include('../includes/scriptorium_inc.php');

if (ALLOW_REGISTRATION == false) {
  header('Location: ' . WEB_PATH . 'create_account.php');
  exit();
}

// does the email and password match the token?
$original_token = $_POST['token'];

if ($original_token == generateAccountToken($_POST['email'],$_POST['password'])) {
  // ok to verify account;
  $quoted_email = $db->quoteSmart(strtolower($_POST['email']));

  $sql = "UPDATE scriptorium_users SET account_state={$ACCOUNT_STATES['active']} WHERE email=$quoted_email LIMIT 1";

  $result = $db->query($sql);
  $sql = <<<SQL

    SELECT email, username, name, user_id, is_admin, locale, account_level
    FROM scriptorium_users WHERE email=$quoted_email
SQL;

  $result = $db->getRow($sql,DB_FETCHMODE_OBJECT);
    

  $_SESSION['auth']['isLoggedIn'] = true;
  $_SESSION['auth']['userName'] = stripslashes($result->username);
  $_SESSION['auth']['name'] = stripslashes($result->name);
  $_SESSION['auth']['email'] = stripslashes($result->email);
  $_SESSION['auth']['userId'] = $result->user_id;
  $_SESSION['auth']['level'] = $result->account_level;
  $_SESSION['locale'] = $result->locale;
  
  if ($result->is_admin == 1) {
    $_SESSION['auth']['isAdmin'] = true;
  }
  
  
  header('Location: ../confirmation_successful.php');
  exit();


 } else {
   // confirmation failed
   $_SESSION['message'] = lib('confirm_fails');
   header('Location: ../confirm_account.php?' . $original_token);
   exit();
}


Return current item: Scriptorium