Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6613931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:16:37+00:00 2026-05-25T20:16:37+00:00

When the POST data is send to: Auth::instance()->register( $_POST ); The data is then

  • 0

When the POST data is send to:

Auth::instance()->register( $_POST );

The data is then validated… If it’s not I assume the Validation Class in Kohana throws an Exception. And then try-catch function catches it. The problem I am having is with this method:

$this->send_confirmation_email($_POST);

It is called even if the data is not valid. I believed that if the data was not valid it would skip everything else and jump to catch… But it seems I was wrong because I am getting a nasty Fatal error from the method to send an email because it cannot find the email address…

try {
        if( ! $optional_checks ) {
           //throw new ORM_Validation_Exception("Invalid option checks");
        }

        $_POST['email_code'] = Auth::instance()->hash(date('YmdHis', time()));

        Auth::instance()->register( $_POST );

        $this->send_confirmation_email($_POST);

        // sign the user in
        Auth::instance()->login($_POST['username'], $_POST['password']);

        // redirect to the user account
        $this->request->redirect('user/profile');
     } catch (Validation_Exception $e) {

So, is there a way so that the method to send an email is skip if the data is not valid?

One could say I should use check() method. Here is why it is a problem:

 Validation::factory($fields)
                    ->rules('username', $this->_rules['username'])
                    ->rule('username', 'username_available', array($this, ':field'))
                    ->rules('email', $this->_rules['email'])
                    ->rule('email', 'email_available', array($this, ':field'))
                    ->rules('password', $this->_rules['password'])
                    ->rules('password_confirm', $this->_rules['password_confirm']);

            if (Kohana::config('useradmin')->activation_code) {
                    Validation::factory($fields)->rule('activation_code', 'check_activation_code', array($this, ':field'));
            }

Thanks in advance for any help.

UPDATE:

It seems now that there is a problem with Kohana Validation class.

Here is the method in my Model_User class:

public function create_user($fields)
{
    Validation::factory($fields)
        ->rules('username', $this->_rules['username'])
        ->rule('username', 'username_available', array($this, ':field'))
        ->rules('email', $this->_rules['email'])
        ->rule('email', 'email_available', array($this, ':field'))
        ->rules('password', $this->_rules['password'])
        ->rules('password_confirm', $this->_rules['password_confirm']);
        //->labels($_labels);

    if (Kohana::config('useradmin')->activation_code) {
        Validation::factory($fields)->rule('activation_code', 'check_activation_code', array($this, ':field'));
    }

    // Generate a unique ID
    $uuid = CASSANDRA::Util()->uuid1();

    //CASSANDRA::selectColumnFamily('UsersRoles')->insert($username, array('rolename' => 'login'));
    CASSANDRA::selectColumnFamily('Users')->insert($uuid, array(
                            'username'      => $fields['username'],
                            'email'         => $fields['email'],
                            'password'      => Auth::instance()->hash($fields['password']),
                            'logins'        => 0,
                            'last_login'        => 0,
                            'last_failed_login' => 0,
                            'failed_login_count'    => 0,
                            'created'       => date('YmdHis', time()),
                            'modify'        => 0,
                            'role'          => 'login',
                            'email_verified'    => $fields['email_code'],
                        ));
}

The code after the Validation class is executed. So even when the data is not valid it still adds a new user to the database.

The test I am doing is with empty inputs.

Here are the rules:

protected $_rules = array(
    'username' => array(
        'not_empty' => NULL,
        'min_length' => array(4),
        'max_length' => array(32),
        'regex' => array('/^[-\pL\pN_.]++$/uD'),    
    ),
    'password' => array(
        'not_empty' => NULL,
        'min_length' => array(8),
        'max_length' => array(42),
    ),
    'password_confirm' => array(
        'matches' => array('password'),
    ),
    'email' => array(
        'not_empty' => NULL,
        'min_length' => array(4),
        'max_length' => array(127),
        'validate::email' => NULL,
    ),
);

Thanks again in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:16:38+00:00Added an answer on May 25, 2026 at 8:16 pm

    The way I setup the rules was wrong and the way I setup the Validation custom rules. Here is the code that resolved the problem:

    protected $_rules = array(
        'username' => array(
            array('not_empty'),
            array('min_length', array(4)),
            array('max_length', array(32)),
            array('regex', array('/^[-\pL\pN_.]++$/uD')),
        ),
        'password' => array(
            array('not_empty'),
            array('min_length', array(8)),
            array('max_length', array(42)),
        ),
        'password_confirm' => array(
            array('matches', array(':validation', ':field', 'password')),
        ),
        'email' => array(
            array('not_empty'),
            array('min_length', array(4)),
            array('max_length', array(127)),
            array('email'),
        ),
    );
    

    Validation:

    $validation = Validation::factory($fields)
            ->rules('username', $this->_rules['username'])
            ->rule('username', array($this, 'username_available'), array(':validation', ':field'))
            ->rules('email', $this->_rules['email'])
            ->rule('email', array($this, 'email_available'), array(':validation', ':field'))
            ->rules('password', $this->_rules['password'])
            ->rules('password_confirm', $this->_rules['password_confirm'])
            ->errors('register/user');
            //->labels($_labels);
    
        if (Kohana::config('useradmin')->activation_code) {
            $validation->rule('activation_code', array($this, 'check_activation_code'), array(':validation', ':field'));
        }
    
        if(!$validation->check())
        {
            throw new Validation_Exception($validation, __('Your registering information is not valid.'));
        }
    

    Thank you all for your support!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm tying to send POST data from one site to another (both sites have
I've got an iPhone App that is supposed to send POST data to my
I use a basic Post to send data to a Django server. The data
How can I send POST data to a URL in PHP (without a form)?
I want to send post data from Iphone. I have to send a dictionary(K-V
Usually when I get POST data it's send from a HTML form and the
I have a error when I tried to send post data with ajax() method.
I send data from javascript to PHP like this: $.ajax({'url': 'my.php', 'type': 'POST', 'data':
I'm trying to send POST data to the current tab, based on this (
I'm trying to figure out the best way to send post data to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.