Welcome Guest, Not a member yet? Register   Sign In
redirect inside controller method to another method with data?
#1

[eluser]mike34666[/eluser]
ok i have web page where the user can select photos to make an album. upon submission i validate the input and if there are errors then i send the user back to the image selecting page with error messages. the way i am implementing it now, when errors are generated and the user is reshown the image select page, the displayed url is the function that processed the form. how to change the url to be the image selecting url? below is a summary of my controller. please let me know a better way to implemented this.
Code:
<?php
class Create_Album extends Controller {
    function __construct() {
        parent::Controller();
    }

    function index() {}

        function select_images() {
        
        // make database call to get image urls
        
        $this->load->view('select_images',  $params);    

    }

    function process_album() {

        // get $_POST input

        // validate input

        if($has_errors == true) {

            // SAME AS select_images()

            // make database call to get image urls

            $params['errors'] = $error_messages;
        
            $this->load->view('select_images',  $params);

        } else {
            
            // write new album data to database

            // show user conformation message that album was created

            $this->load->view('process_album', $params);
        }
    }
?>
#2

[eluser]WanWizard[/eluser]
If you take this approach, your URL doesn't change. If you want that, you will have to redirect.

You can use the flashdata methods of the session library to pass data on to the controller that has to process the request.




Theme © iAndrew 2016 - Forum software by © MyBB