Ejemplo n.º 1
0
 function create()
 {
     $ide = new IDE();
     if ($ide->isLogged()) {
         $ide->redirect('../account');
     }
     $this->load->helper('form');
     if ($_POST) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('name', 'Account Name', 'required|min_length[4]|max_length[32]|callback__account_exists|alpha');
         $this->form_validation->set_rules('password', 'Password', 'required|matches[repeat]|min_length[4]|max_length[255]');
         $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
         if ($this->form_validation->run() == TRUE) {
             require APPPATH . 'config/ide_default.php';
             $ots = POT::getInstance();
             $ots->connect(POT::DB_MYSQL, connection());
             $account = new OTS_Account();
             $name = $account->createNamed($_POST['name']);
             $account->setPassword($_POST['password']);
             $account->setEmail($_POST['email']);
             $account->setCustomField('premdays', PREMDAYS);
             try {
                 $account->save();
                 $_SESSION['logged'] = 1;
                 $_SESSION['name'] = $_POST['name'];
                 $ide->redirect('../account');
             } catch (Exception $e) {
                 error($e->getMessage());
             }
         }
     }
     #Load view of creating account
     $this->load->view('create');
 }
Ejemplo n.º 2
0
<?php

// to not repeat all that stuff
include 'quickstart.php';
// creates new account object
$account = new OTS_Account();
// generates new account
$name = $account->createNamed();
// give user his name
echo 'Your account name is: ', $name;