English 中文(简体)
如何通过改头通过验证错误数据?
原标题:How to pass validation error data through redirect()?

我有一页载有表格,任何用户提交数据时,数据都交给控制员,如果出现任何错误,则由控制人对验证进行核对,然后将数据传送给模型。

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

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

以上编码是工作上的罚款,但问题是在将用户转至上页之后(该页包含表格),没有显示验证错误。

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?

预兆:

Solution:

在我的控制员中:

   $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>";
    }

    ?>

因此,我可以通过从控制人向上页的转头传递验证错误数据。

最佳回答

你们可以尝试来自CI会议图书馆的闪电数据。 该系统提供下一次服务器申请的数据。

$this->session->set_flashdata( errors , validation_errors());

redirect($this->input->post( redirect ));
问题回答

暂无回答




相关问题
PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

What s the proper MVC way to do this....?

Quick question about general MVC design principle in PHP, using CodeIgniter or Kohana (I m actually using Kohana). I m new to MVC and don t want to get this wrong... so I m wondering if i have ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

CodeIgniter adding semicolons

How do I stop CodeIgniter adding semicolons ; to data sent via POST that contains ampersand &? For example it is converting "a=1&b=2&c=3" into "a=1&b;=2&c;=3". From looking on the forums ...

Best way to make Admin pages in CodeIgniter?

I m working on an app in CodeIgniter, and I want to have admin pages for several of the objects in the application, and I m wondering what would be the better way to put these into an MVC structure. ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签