Welcome Guest, Not a member yet? Register   Sign In
Header and redirect
#1

[eluser]finord[/eluser]
Hello, I have a problem with a script, not because they will not let me redirect. I have done looking at the guide, and without output anything(only process something) in the redirect page.

I've been looking at the forum, but I have not found anything that I can help

Here is the Code: add.php
Code:
<?
class add extends Controller

     {
        function add()
         {
           parent::Controller();
           $this->load->database();
         //  $this->load->model->('op_que_trnsfer');

          }

        function index() {
}

(other functions....)

function cl(){ //First Step
?>

<a href="http://www.example.com/add/ct">dr</a>  
&lt;? }

function ct(){  //Second Step
$this->load->helper('url');
$hoy = date("m.d.y His");  
$us="loc";
$hoy1=$hoy.$us;
$key=md5($hoy1);
redirect('add/ct2/'.$key, 'location', 301);
}

function ct2($key){ //Third Step
echo $key;
}

Im want to do:
Link to ct->in ct, process key, and send it by url, and redirect->Output it in ct2

Plz, if someone else can help me. Thanks ^^

EDIT:I forgot the error:

Code:
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /usr/home/web_domain/www/system/application/config/database.php:1)

Filename: helpers/url_helper.php

Line Number: 485

In ulr_helper, Line Numer:485:

Code:
if ( ! function_exists('redirect'))
{
    function redirect($uri = '', $method = 'location', $http_response_code = 302)
    {
        switch($method)
        {
            case 'refresh'    : header("Refresh:0;url=".site_url($uri));
                break;
            default            : header("Location: ".site_url($uri), TRUE, $http_response_code);
                break;
        }
        exit;
    }
}
#2

[eluser]sophistry[/eluser]
looks like your config/database.php file is emitting something... check that file for any echo, print, or print_r statements or that sort of thing. also make sure there is not any extra whitespace at the top of bottom of the file.
#3

[eluser]AndrewMalachel[/eluser]
From what I see, you just want to call another controller function (within the same class) from other function, right?
Rather than using the Redirect function, why don't you call the ct2 function directly from the ct function?

so your code are changed to be something like:
Code:
function ct(){  //Second Step

// ....

// redirect('add/ct2/'.$key, 'location', 301); // we'll change this into :
$this->ct2($key);                              // this...
}

function ct2($key){ //Third Step
echo $key;
}

hope it helps...
#4

[eluser]finord[/eluser]
Hello, sophistry was right, there were empty spaces in the config/database.

And AndrewMalachel, I need to have the key in the url, so use redirect.

Thanks to all ^^




Theme © iAndrew 2016 - Forum software by © MyBB