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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:24:34+00:00 2026-05-26T20:24:34+00:00

hi i am currently learning code igniter i am pretty much new to this

  • 0

hi i am currently learning code igniter i am pretty much new to this i have an issue with code igniter validations. I cant figure out what i am doing wrong please guide me.
currently what is happening is that whenever i submit with empty fields i am redirected to same page but when i populate the fields i am redirected to same page but the page is blank.
this is my user class

class User extends CI_Controller {

    function User() {
        parent::__construct();

        $this->view_data['base_url'] = base_url();
    }

    function index() {

        $this->register();
    }

    function register() {

        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_numeric|min_length[6]');
        if ($this->form_validation->run() == false) {
            $this->load->view('view_register', $this->view_data);
        } else {
            $username=$this->input->post('username');
        }
    }

}

and this is my view_register.php (view)

<body>
    <h1>User Registration</h1>
    please fill in following details
    <?php
    echo form_open(base_url().'user/register');
    ?>
    <?php
    $username = array(
        'name' => 'username',
        'id' => 'username',
        'value' => ''
    );
    $password = array(
        'name' => 'password',
        'id' => 'password',
        'value' => ''
    );
    $con_password = array(
        'name' => 'con_password',
        'id' => 'con_password',
        'value' => ''
    );
    $email = array(
        'name' => 'email',
        'id' => 'email',
        'value' => ''
    );
    ?>

    <ul>
        <li>
            <label>Username</label>
            <div>
                <?php echo form_input($username); ?>
            </div>
        </li>
    </ul>
    <ul>
        <li>
            <label>Email</label>
            <div>
                <?php echo form_input($email); ?>
            </div>
        </li>
    </ul>
    <ul>
        <li>
            <label>Password</label>
            <div>
                <?php echo form_password($password); ?>
            </div>
        </li>
    </ul>
    <ul>
        <li>
            <label>Confirm</label>
            <div>
                <?php echo form_password($con_password); ?>
            </div>
        </li>
    </ul>
    <ul>
        <li>
            <div>
                <?php echo form_submit(array('name' => 'register'), 'Register'); ?>
            </div>
        </li>
    </ul>
    <?php echo form_close(); ?>
</body>
  • 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-26T20:24:35+00:00Added an answer on May 26, 2026 at 8:24 pm

    Beacuse you’re not loading a view in case validation is right, so CI calls again that controller, but displays nothing:

    function register() {
    
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_numeric|min_length[6]');
    
        if ($this->form_validation->run() == false)
        {
            $this->load->view('view_register', $this->view_data);
        } else
        {
            $username=$this->input->post('username');
            $this->load->view('success');  // <------ put your view for success here
        }
    }
    

    Also, you should be opening the form with this, instead of your code:

     echo form_open('user/register');
    

    it works out by itself the correct url (anologuely to site_url());

    Try putting, also, echo form_error('username') under the username input to display the validation errors.

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

Sidebar

Related Questions

Currently learning Scheme/Racket and have problem running this piece of code. (if (or (<
I'm currently learning Hibernate, and I've stumbled into this issue: I have defined 3
I'm currently learning php, and I'm testing out oop and classes. My code is:
I'm currently learning Win32 using this tutorial , and I have a hard time
I'm currently learning scala. Why this code doesn't work: class GenClass[T](var d : T)
im currently learning python (in the very begining), so I still have some doubts
im currently learning stacks in java and have a quick question. what will the
I'm currently learning Ruby and RoR and I stumbled across this declaration: link_to_remote(name, options
I am currently learning Perl. I have Perl hash that contains references to hashes
I'm currently learning c++ on a linux machine. I've got the following code for

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.