Welcome Guest, Not a member yet? Register   Sign In
Redirect after a form submission not working
#1

[eluser]Ray Julich[/eluser]
I have an application with a form. Let's call it form.php. I submit the form to form.php, I verify it, I create a few flashdata variables and then redirect to another page to be processed. I am getting an error when I try to redirect the page.

Here is the code once I've submitted the form:
Code:
$this->session->set_flashdata('field1',$this->input->post('field1'));
$this->session->set_flashdata('field2',$this->input->post('field2'));
$this->session->set_flashdata('field3',$this->input->post('field3');
$this->session->set_flashdata('field4',$this->input->post('field4');
                
//Redirect the user
redirect('next_page', 'location');

Right now when I submit the form, I get a "The website cannot display the page" error page in my browser. The error is on the form.php, not on the redirect page. I have other pages in my application that use redirects and they work fine, but this is the only page in my application that uses flashdata. I did want to point out that I started use https in my application a few weeks ago and it seemed to have been working before I made that change. I don't know if it's related or not.
#2

[eluser]tonanbarbarian[/eluser]
is that the exact redirect statement you are using? because if it is that might not be a valid url unless you have a controller call new_page

you are being a little vague with this and should provide the exact code so we can see what is really going on
#3

[eluser]Ray Julich[/eluser]
Sorry, I was pretty vague. I am working on a reservation system. A person fills out their criteria for reserving a laptop. Once the controller where the form resides verifies the information, it redirects to an available_resources controller, which will tell the user what laptop is available to reserves based on their criteria.

Here is the actual code:
Code:
$this->session->set_flashdata('purpose',$this->input->post('purpose'));
$this->session->set_flashdata('category',$this->input->post('category')); //For example - Laptop
$this->session->set_flashdata('pickupdatetime',$this->input->post('pickupdate') . ' ' . $this->input->post('pickuptime') . ':00');
$this->session->set_flashdata('returndatetime',$this->input->post('returndate') . ' ' . $this->input->post('returntime') . ':00');
                
//Redirect the user
redirect('available_resources', 'location');

I have been viewing this in Internet Explorer, but I looked at this in Firefox yesterday. When looking at it in Firefox, it does redirect to the available_resource controller, but the page is blank.
#4

[eluser]InsiteFX[/eluser]
Code:
$data = array(
    'purpose' => $this->input->post('purpose'),
    'category' => $this->input->post('category'),
    'pickupdatetime' => $this->input->post('pickupdate') . ' ' . $this->input->post('pickuptime') . ':00'),
    'returndatetime' => $this->input->post('returndate') . ' ' . $this->input->post('returntime') . ':00')
);

$this->session->set_flashdata($data);
                
//Redirect the user
redirect('available_resources', 'location');

You may need to use:
Code:
$this->session->keep_flashdata($data);

InsiteFX
#5

[eluser]Ray Julich[/eluser]
Stupid me. I've got it figured out. The "error" was happening when I was loading a custom model. In looking at the model, it was looking for POST data instead flashdata. Once I made that change, things are working again.




Theme © iAndrew 2016 - Forum software by © MyBB