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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:51:26+00:00 2026-05-26T11:51:26+00:00

I have a page that contains a form and when any user submits it,

  • 0

I have a page that contains a form and when any user submits it, the data goes to a controller and the controller checks the validation, if there is any error it redirects the user to the previous page( the page that contains the form), otherwise it sends data to models.

To redirect to the previous page from controller (if there is any validation error), I have the following code

        redirect($this->input->post('redirect'));

The above code is working fine but the problem is after it redirects the user to the previous page(The page that contains the form) it is not displaying the validation errors.

So would you please kindly tell me how to pass the validation error information through this “redirect” code I posted above and show the validation error message on that page?

Thanks in Advance 🙂

Solution:

In my controller:

   $redirect=$this->input->post('redirect'); //  << for this I have- <input name="redirect" type="hidden" value="<?= $this->uri->uri_string() ?>" />         in my view file

   $this->session->set_flashdata('errors', validation_errors());
   redirect($this->input->post('redirect')); 

In my view file:

   <?php

    if ($this->session->flashdata('errors')){ //change!
    echo "<div class='error'>";
    echo $this->session->flashdata('errors');
    echo "</div>";
    }

    ?>

Thus I can pass validation error data through redirect from controller to previous page

  • 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-26T11:51:27+00:00Added an answer on May 26, 2026 at 11:51 am

    You can try flashdata from CI’s session library. It makes the data available for the next server request.

    $this->session->set_flashdata('errors', validation_errors());
    
    redirect($this->input->post('redirect'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have an aspx page that contains something like.... <form id=form1
I have a page on a website that contains a secure form inside an
I have a page that contains a user control that is just a personalized
I have a dropdown, that contains some list of StudentCode... when user select any
I have a JSF page that contains a form with several elements, that correspond
I have an ASP.NET page that contains a form and a button. In order
i have a website page that contains only data of which one field gives
I have a ASPX Page that contains several user controls, which are loaded dynamically
In a web application, I have a page that contains a DIV that has
I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)

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.