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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:32:15+00:00 2026-06-05T21:32:15+00:00

The controller function: function signup() { $bool1 = $this->form_validation->run(‘username’); $bool2 = $this->form_validation->run(’email’); $bool3 =

  • 0

The controller function:

function signup()
        {

            $bool1 = $this->form_validation->run('username');
            $bool2 = $this->form_validation->run('email');
            $bool3 = $this->form_validation->run('pass');

            var_dump($bool1);
            var_dump($bool2);
            var_dump($bool3);

            $this->load->view('myform');

        }

The view code:

<?php $this->load->view('includes/header'); ?>


<?php

    $data_username = array(

        'name' => 'username',
        'onBlur' => 'username_val()',
        'maxlength' => 50,

    );

    $data_email = array(

        'name' => 'email',
        'onBlur' => 'email_val()',
        'maxlength' => 50

    );

    $data_pass = array(

        'name' => 'pass',
        'onBlur' => 'pass_val()',
        'maxlength' => 50,
        'autocomplete' => 'off'

    );

?>

    <div id="body">

        <div id="bodycontent">

            <table class="login_table">

            <?php $attr = array( 'onsubmit' => 'return final_val()' ); echo form_open('signup',$attr); ?>

            <tr><td>Username: </td><td><?php echo form_input($data_username); ?><span name="username_error" >&nbsp;&nbsp;<?php echo form_error('username'); ?></span></td></tr>

            <tr><td>Email: </td><td><?php echo form_input($data_email); ?><span name="email_error">&nbsp;&nbsp;<?php echo form_error('email'); ?></span></td></tr>


            <tr><td>Password: </td><td><?php echo form_password($data_pass); ?><span name="pass_error">&nbsp;&nbsp;<?php echo form_error('pass'); ?></span></td></tr>

            <tr><td><input type="submit" value="SIGN UP!" name="signup"/></td></tr>

                <?php echo form_close(); ?>

            </table>


        </div>

    </div>

<?php $this->load->view('includes/footer'); ?>

Form Validation Config:

<?php
$config = array(
                 'username' => array(

                                    array(
                                            'field'   => 'username',
                                            'label' => 'nama',
                                            'rules' => 'required|min_length[1]|max_length[50]|strip_tags|encode_php_tags|htmlspecialchars'
                                         )

                                    ),
                 'email' => array(
                                    array(
                                            'field'   => 'email',
                                            'label' => 'EMAIL',
                                            'rules' => 'required|min_length[1]|max_length[50]|valid_email|strip_tags|encode_php_tags|htmlspecialchars'
                                         )
                                    ),     

                'pass' => array(
                        array(
                                'field'   => 'pass',
                                'label' => 'PASSWORD',
                                'rules' => 'required|min_length[6]|max_length[256]|strip_tags|encode_php_tags|htmlspecialchars'
                        )
                ),/*

                'passconf' => array(
                        array(
                                'field'   => 'passconf',
                                'label' => 'PASS_CONF',
                                'rules' => 'required|min_length[6]|max_length[32]|matches[pass]|strip_tags|encode_php_tags|htmlspecialchars'
                        )
                ),*/

    'title' => array(

        array(
            'field'   => 'title',
            'label' => 'Title field',
            'rules' => 'required|min_length[1]|max_length[60]|strip_tags|encode_php_tags|htmlspecialchars'
        )

    )

               );



?>

Javascript is turned off.

The problem: Once the username field is submitted with any value, all returns true. And if all is given value except for username field, all returns false.

What’s wrong with the code? Thanks.

UPDATE:

Thanks @TheSwiftExchange for pointing this out:
You dont run each variable through the validation – you run the WHOLE form through the validation ONCE.

So, I changed the config file to:

$config = array(
                 'signup' => array(

                                    array(
                                            'field'   => 'username',
                                            'label' => 'nama',
                                            'rules' => 'required|min_length[1]|max_length[50]|strip_tags|encode_php_tags|htmlspecialchars'
                                         ),

                                     array(
                                         'field'   => 'email',
                                         'label' => 'EMAIL',
                                         'rules' => 'required|min_length[1]|max_length[50]|valid_email|strip_tags|encode_php_tags|htmlspecialchars'
                                     ),


                                     array(
                                         'field'   => 'pass',
                                         'label' => 'PASSWORD',
                                         'rules' => 'required|min_length[6]|max_length[256]|strip_tags|encode_php_tags|htmlspecialchars'
                                     )

                                  )
)

And it works nicely now. 😉

  • 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-05T21:32:16+00:00Added an answer on June 5, 2026 at 9:32 pm

    You dont run each variable through the validation – you run the WHOLE form through the validation ONCE.

    function signup()
        {
    
            if ($this->form_validation->run())
            {
                echo "ok";
            }
            else
            {
                echo validation_errors();
            }
    
            $this->load->view('myform');
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php class Email extends Controller { function Email() { parent::Controller(); $this->load->library('email'); } function index()
i have been trying to pass some variables to model through the controller function
i have this controller function: Public Function Index(ByVal id As System.Nullable(Of Integer)) As ActionResult
I have a working controller and library function, but I now need to pass
I have this in my controller: function foo() { // my code redirect(site_url('competitor/main'), 'refresh');
I have this code: // controller function contact($token) { $this->layout = 'ajax'; } //
I tried to pass Array of javascript classes in $.post function, but in controller
I want to be able to user query strings in this fashion. Domain.com/controller/function?param=5&otherparam=10 In
This is my model: function getGalleryListing() { $this->db->select('photo.id,photo.src,photo.title,photo.user_id,users.id,users.username'); $this->db->from('photo'); $this->db->join('users', 'users.id = photo.user_id'); $query
The controller function startpage:function(a){ var model1 = this.store.getAt(a.index); App.views.start.load(model1); App.views.viewport.reveal('start'); }, how to get

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.