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 8552471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:25:51+00:00 2026-06-11T14:25:51+00:00

How can i validate something i did not get from a form. I want

  • 0

How can i validate something i did not get from a form. I want to validate my variable and i want this rule to be is_uniqe() to check for duplicates.

I have tried setting a rule in the $rules array as array( ‘field’ => $this->characterNAME, ‘rules’ => ‘is_unique[members.char_name]) yet no effect i tried calling the is_unique() on its own yet no effect and i tried to asign the variable to $_POST[‘charNAME’] = $this->characterNAME; and then pass that to set_rules() yet no effect.

How can i validate my variable ?

My code:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Registration extends CI_Controller {

var $characterNAME = "";
var $characterCORP = "";
var $characterALLY = "";
var $characterJDAT = "";

function __construct() {
    parent::__construct();
    $this->load->helper('form');
    $this->load->library('form_validation');
    $this->load->model('Registration_model', 'reg');
}

public function index()
{

    $this->load->view('registration_view');
}

function insert()
{

    $rules = array(
        array(
            'field' => 'username',
            'label' => 'Username',
            'rules' => 'required|min_length[6]|max_length[250]|is_unique[members.username]'
            ),
        array(
            'field' => 'password',
            'label' => 'Password',
            'rules' => 'required|min_length[6]|max_length[250]|md5'
            ),
        array(
            'field' => 'apiid',
            'label' => 'apiid',
            'rules' => 'required|integer|min_length[6]|max_length[250]|callback_api_check[' . $this->input->post('apikey') . ']'
            ),
        array(
            'field' => 'apikey',
            'label' => 'apikey',
            'rules' => 'required|min_length[6]|max_length[255]'
            ),
        );

    $_POST['charNAME'] = $this->characterNAME;
    $this->form_validation->set_rules('charNAME', 'CharacterName', 'is_unique[members.char_name]');
    $this->form_validation->set_rules($rules);

    if($this->form_validation->run() == FALSE) 
    {
        $this->load->view('registration_view'); 
    } else {

        // PROCESS REGISTRATION 
        $this->reg->add_user($_POST['username'], $_POST['password'], $_POST['apiid'], $_POST['apikey'], $this->characterNAME, $this->characterCORP, $this->characterALLY, $this->characterJDAT);
        // REDIRECT
        $this->load->view('registration_done');
    }
}

function api_check($apiid, $apikey) 
{
    $url = 'http://api.eveonline.com/account/Characters.xml.aspx?keyID='.$apiid.'&vCode='.$apikey;

    $xml = new DOMDocument();
    $xml->load($url);

    $chars = $xml->getElementsByTagName('row');

    foreach ($chars as $character) 
    {
        $charid = $character->attributes;
        $curl = 'http://api.eveonline.com/eve/CharacterInfo.xml.aspx?keyID='. $apiid . '&vCode='.$apikey . '&characterID=' . $charid->item(1)->nodeValue;

        $cxml = new DOMDocument();
        $cxml->load($curl);

        $corp = $cxml->getElementsByTagName("corporation");
        $ally = $cxml->getElementsByTagName("alliance");
        $char = $cxml->getElementsByTagName("characterName");
        $jdat = $cxml->getElementsByTagName("corporationDate");

        // Check database instead

        if($this->reg->validate_entity($corp->item(0)->nodeValue) || $this->reg->validate_entity($ally->item(0)->nodeValue)) 
        {
            $this->characterNAME = $char->item(0)->nodeValue;
            $this->characterCORP = $corp->item(0)->nodeValue;
            $this->characterALLY = $ally->item(0)->nodeValue;
            $this->characterJDAT = $jdat->item(0)->nodeValue;
            return true;
        }

    }
    $this->form_validation->set_message('api_check','None of the characters on this account are allowed to join.');
    return false;
}


}
  • 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-06-11T14:25:52+00:00Added an answer on June 11, 2026 at 2:25 pm

    You can validate that your form input isn’t a duplicate by calling the is_unique function directly, via (example):

    $this->form_validation->is_unique($email, ‘users.email’);

    This will return a boolean true/false. True = Is Unique — in this case

    Therefore, you can put that in an if() and check it that way…

    Hope this helps

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

Sidebar

Related Questions

How can a validation exclude a regexp? I'm looking for something like this: validates_format_of
I want to write a function which can validate a given value (passed as
Can I validate a form on button click without submitting the whole form using
How can I validate file size from client side. It can be controlled via
I want a class in JavaScript through which I can validate all the Input
This is something of a follow-up question to my question here . You can
I trying to get the beforesubmit option to work so I can validate the
I am wanting to build a validator (javascript) that can validate numbers from different
You can validate a model object with EF 5 Code-First like that: var validationResult
I am looking for a Java framework which can validate order of elements in

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.