Welcome Guest, Not a member yet? Register   Sign In
Redirection Problem
#11

[eluser]karlaredor[/eluser]
Yes, I was able to save data to the database successfully.
#12

[eluser]Yash[/eluser]
Now what happen when you pass

Code:
redirect('controller/somefunction','refresh');


Note: In order for this function to work it must be used before anything is outputted to the browser since it utilizes server headers.
#13

[eluser]karlaredor[/eluser]
Unfortunately, it did not work. I just tried it.

Code:
function save()
    {
    
        $title = $_POST['title'];
        $slug = $_POST['slug'];
        $pagebody = $_POST['pagebody'];
        $data = array(
                       'title' => $title,
                       'slug' => $slug,
                       'pagebody' => $pagebody
                    );
        $data = $this->db->escape_str($data);
        $this->db->insert('pages', $data);
        redirect('page/index', 'refresh');
        
    }
#14

[eluser]Yash[/eluser]
[quote author="hvalente13" date="1217051195"]

1. Have you loaded the url helper?

Code:
$this->load->helper('url');
[/quote]

also what happens?

check index.php and set_errors to E_ALL (if you change this ..so that u can see errors.)

if still fails then in your config.php

The
| threshold determines what gets logged. Threshold options are:
|
| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages
|
| For a live site you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 4; // change 0 to 4 now check log folder for logs
#15

[eluser]karlaredor[/eluser]
I tried adding this code:

Code:
$this->load->helper('url');

after calling redirect.

Still the same. It still won't redirect.
#16

[eluser]Yash[/eluser]
ok Try redirect alone without save.

I mean just try redirect

before that add this into constructor
$this->load->helper('url');
#17

[eluser]karlaredor[/eluser]
I tried this:

Code:
function save()
{
  $this->load->helper(’url’);
  redirect('page/index', 'refresh');
}

and I got this:

Quote:A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant ’url’ - assumed '’url’'

Filename: controllers/page.php

Line Number: 50
An Error Was Encountered

Unable to load the requested file: helpers/’url’_helper.php
#18

[eluser]Yash[/eluser]
open autoload.php
Code:
| Prototype:
|
|    $autoload['helper'] = array('url', 'file');
*/

$autoload['helper'] = array('url','html','file','form', 'text','date','security');
replace with one
then run
Code:
function save()
{
  redirect('page/index', 'refresh');
}
#19

[eluser]karlaredor[/eluser]
Now it's working.

I tried deleting some extra lines after this

Code:
<?php

some code here

?>

And it did the trick. Thank you for helping me out with this.
#20

[eluser]Yash[/eluser]
Your welcome




Theme © iAndrew 2016 - Forum software by © MyBB