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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:11:48+00:00 2026-05-29T07:11:48+00:00

I have the form_validation library loaded in my controller and the form validation itself

  • 0

I have the form_validation library loaded in my controller and the form validation itself is working, but when using set_value() it’s not populating the form fields. Here is the code in to controller:

function addUser()
{
    $this->form_validation->set_rules('firstName', 'firstname', 'trim|required|max_length[30]');
    $this->form_validation->set_rules('surname', 'surname', 'trim|required|max_length[30]');
    $this->form_validation->set_rules('emailAddress', 'email address', 'trim|required|valid_email|is_unique[users.email]|max_length[255]');
    $this->form_validation->set_rules('password', 'password', 'trim|required|max_length[20]|min_length[5]');
    $this->form_validation->set_rules('passwordVerify', 'password verification', 'trim|required|max_length[20]|min_length[5]');

    if($this->form_validation->run() === FALSE) {
        $this->session->set_flashdata('formValidationError',  validation_errors('<p class="error">', '</p>'));
        redirect('/member/register');
    } else {
        echo 'Passed';
    }
}

And here is the code in the view:

    <?php echo $this->session->flashdata('formValidationError'); ?>
<form method="POST" action="<?php echo site_url('member/addUser'); ?>">
    <fieldset>
        <legend>Create a FREE account</legend>
        <div>
            <label for="firstName">Firstname</label>
            <input type="text" name="firstName" value="<?php echo set_value('firstName'); ?>" maxlength="30">
        </div>

        <div>
            <label for="surname">Surname</label>
            <input type="text" name="surname" value="<?php echo set_value('surname'); ?>" maxlength="30">
        </div>

        <div>
            <label for="emailAddress">Email Address</label>
            <input type="text" name="emailAddress" value="<?php echo set_value('emailAddress'); ?>" maxlength="255">
        </div>

        <div>
            <label for="password">Password</label>
            <input type="password" name="password" maxlength="20">
        </div>

        <div>
            <label for="passwordVerify">Verify Password</label>
            <input type="password" name="passwordVerify" maxlength="20">
        </div>

        <button type="submit">Register</button>
    </fieldset>
</form>

Is there something I am missing? Is the redirect causing the issue?

  • 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-29T07:11:49+00:00Added an answer on May 29, 2026 at 7:11 am

    It is not working because you are using redirection.

    Instead of

        $this->session->set_flashdata('formValidationError',  validation_errors('<p class="error">', '</p>'));
        redirect('/member/register');
    

    just for testing, try to load the view

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

    and you will see.

    set_value requires that the form validation ran in the same context… you lose this context when you redirect.

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

Sidebar

Related Questions

I have created an form validation using ajax/php. Each text box is validated using
Form validation for check boxes only seems to be working in IE....? Anyone have
I am using jquery validation plugin for form validation. I have added a custom
I have a code for form validating in my CodeIgniter app: $this->load->library('form_validation'); $this->form_validation->set_rules('message', 'Message',
I am using the Webshims library for polyfilling the validation of a HTML5 form.
I have a multi-lingual page where I want to display form validation error in
I have a small jQuery plugin that I use for form AJAX validation. There
I have a Django form that needs to do some client-side validation before submitting
I have a registration form leveraging xVal to handle all validation on the form.
In good old MFC, the DDX routines would have built in validation for form

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.