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

  • Home
  • SEARCH
  • 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 4029274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:19:29+00:00 2026-05-20T11:19:29+00:00

I could use some guidance in how to proceed on form validation in CodeIgniter.

  • 0

I could use some guidance in how to proceed on form validation in CodeIgniter. I am using CodeIgniter’s built-in form validation and works fine as far as it goes. It returns individual error messages for each field where there is an error by using and wrapping it in some HTML/CSS for styling:

<?php echo validation_errors('<p class="error">'); ?>

But what we want to do is highlight the fields where there are errors. CI will let you put the error messages next to where the form errors are. But it requires you to use the error message for the value, like this:

<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />

which by the way is in CI’s manual in non-CI syntax, which puzzles me. Anyway, we also want the data from the field when the form is submitted to be preserved and returns. So I’ve done:

$email = array('name' => 'email', 'value' => $em);
      ?><div style="padding:5px;">Email* </div><?php echo form_input($email) . '<br/>';

$em is returned from the controller like this:

$data['em'] = $this->input->post('email');

So my question is, how do I accomplish all of what is outlined above? Obviously, what CI suggests and what I have done collide. But I don’t know how else to do it, so I could use some help.

EDIT: Upon further digging, I see that you can put the error message next to the field by doing this:

<?php echo form_error('email'); ?>

But I’m not getting any message upon an error, even though I have the rule written and I get an error with the first line of code above.

  • 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-20T11:19:30+00:00Added an answer on May 20, 2026 at 11:19 am

    In order to display error individually you should use the function form_error(’email’). And for you to get a value of a field being checked, use the function set_value(’email’). For these two functions to work, you would have had to, in your controller, set a rule for the ’email’ field. Where you specify wich validation rules apply to that field.

    <?php echo form_error('email'); ?>
    <input type="text" name="username" value="<?php echo set_value('email'); ?>" size="50" />
    

    source: http://codeigniter.com/user_guide/libraries/form_validation.html#individualerrors

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

Sidebar

Related Questions

Could someone give me some guidance on when I should use WITH (NOLOCK) as
I could use some help writing a regular expression. In my Django application, users
I could use some help creating an XSL template that will take a string
I am getting the following error and could use some help resolving it. Anyone
We're having a small issue and could use some help - we have the
I've inherited a rather large application that really could use some cleanup. There is
I have a piece of code here that i really could use some help
This seems to be an overlooked area that could really use some insight. What
I've done some Python but have just now starting to use Ruby I could
I have a design conundrum that I could use some feedback on, so I'm

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.