Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How do I redirect?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  19 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
glevine  
View profile  
 More options Mar 18 2012, 10:28 pm
From: glevine <levine.g...@gmail.com>
Date: Sun, 18 Mar 2012 19:28:02 -0700 (PDT)
Local: Sun, Mar 18 2012 10:28 pm
Subject: How do I redirect?

I have the following code:

class TestsController extends AppController
{
  public function index()
  {
    print 'in the index';
  }

  public function change()
  {
    print 'before redirect';
    $this->redirect(array('controller' => 'test', 'action' => 'index'));
    print 'after redirect';
  }

}

When I visit www.mysite.com/test/change/ I get a page with "before
redirect" and the URL is still www.mysite.com/test/change/.<http://www.mysite.com/test/change/>I don't get "after redirect" or "in the index". What am I doing wrong?

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
thatsgreat2345  
View profile  
 More options Mar 19 2012, 2:07 am
From: thatsgreat2345 <thatsgreat2...@gmail.com>
Date: Sun, 18 Mar 2012 23:07:04 -0700 (PDT)
Local: Mon, Mar 19 2012 2:07 am
Subject: Re: How do I redirect?

You can not send output to the webpage and then redirect.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Milina Udara  
View profile  
 More options Mar 19 2012, 5:16 am
From: Milina Udara <milina...@gmail.com>
Date: Mon, 19 Mar 2012 14:46:08 +0530
Local: Mon, Mar 19 2012 5:16 am
Subject: Re: How do I redirect?

can we do some process after redirect.(Not printion)

On Mon, Mar 19, 2012 at 11:37 AM, thatsgreat2345
<thatsgreat2...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
euromark  
View profile  
 More options Mar 19 2012, 7:56 am
From: euromark <dereurom...@googlemail.com>
Date: Mon, 19 Mar 2012 04:56:28 -0700 (PDT)
Local: Mon, Mar 19 2012 7:56 am
Subject: Re: How do I redirect?

no you can't! or: you really shoudn't
you should simply do everything before redirecting.

theoretically, you can manually call exit() if you set the exit param to
false on redirect.
but to me this makes no sense.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
glevine  
View profile  
 More options Mar 19 2012, 10:56 am
From: glevine <levine.g...@gmail.com>
Date: Mon, 19 Mar 2012 07:56:09 -0700 (PDT)
Local: Mon, Mar 19 2012 10:56 am
Subject: Re: How do I redirect?

Right, so in the example I was mainly just wanting to show that I was
reaching those points in the code. Theoretically, if I remove the "print
'before redirect';" statement then I should never see "after redirect" but
I should see "in the index" upon the new page load (since that is post
redirect).

For some reason, I was still unable to redirect when I wasn't printing to
the screen before the call to exit. However, I may have just been tired and
didn't realize I still had a print before exit. So I'll try again and
respond back with the results.

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Bowler  
View profile  
 More options Mar 19 2012, 3:33 pm
From: Brian Bowler <bbowle...@gmail.com>
Date: Mon, 19 Mar 2012 15:33:42 -0400
Local: Mon, Mar 19 2012 3:33 pm
Subject: Re: How do I redirect?

Please do I have the exact same problem and would like to know if you get
this fixed.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
thatsgreat2345  
View profile  
 More options Mar 19 2012, 3:53 pm
From: thatsgreat2345 <thatsgreat2...@gmail.com>
Date: Mon, 19 Mar 2012 12:53:44 -0700 (PDT)
Local: Mon, Mar 19 2012 3:53 pm
Subject: Re: How do I redirect?

Your problem is you are redirecting to test controller when in fact you
should be redirecting to tests controller.

$this->redirect(array('controller' => 'tests', 'action' => 'index'));


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
glevine  
View profile  
 More options Mar 19 2012, 9:41 pm
From: glevine <levine.g...@gmail.com>
Date: Mon, 19 Mar 2012 18:41:51 -0700 (PDT)
Local: Mon, Mar 19 2012 9:41 pm
Subject: Re: How do I redirect?

@thatsgreat2345 That was just a typo.

Commenting out the print statements in the change method has no effect. I
never see the "in the index" print statement and the browser simply shows a
blank page with a couple of warnings about changing the salt and
cipherSeed. The url in the location bar remains
http://www.example.com/tests/change.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
thatsgreat2345  
View profile  
 More options Mar 19 2012, 11:12 pm
From: thatsgreat2345 <thatsgreat2...@gmail.com>
Date: Mon, 19 Mar 2012 20:12:50 -0700 (PDT)
Local: Mon, Mar 19 2012 11:12 pm
Subject: Re: How do I redirect?

First off, change your core configuration so you aren't using the default
salt and cipherSeed (this can be found in your apps core.php file in the
Config folder), that is if this app matters which it seems like it is just
a practice app but still good practice.
It appears your routes(app Config folder, routes.php) are set so that when
you visit your tests index it will direct you towards the default home page
that is set in the cake core.
I recommend modifying this, so that when people visit your index (/) it is
routed to the controller and action of your choice. Which in this case
seems to be tests controller and action index.
The line of code will look like this
Router::connect('/', array('controller' => 'pages', 'action' => 'display',
'home'));
Modify it to
Router::connect('/', array('controller' => 'tests', 'action' => 'index');
For the record, it is not recommended to use print when debugging, if you
just want to do browser debugging use cakes debug function. You can use it
anywhere, and it accepts any type of variable and will output it cleanly.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AD7six  
View profile  
 More options Mar 20 2012, 3:22 am
From: AD7six <andydawso...@gmail.com>
Date: Tue, 20 Mar 2012 00:22:36 -0700 (PDT)
Local: Tues, Mar 20 2012 3:22 am
Subject: Re: How do I redirect?

On Tuesday, 20 March 2012 02:41:51 UTC+1, glevine wrote:

> @thatsgreat2345 That was just a typo.

> Commenting out the print statements in the change method has no effect. I
> never see the "in the index" print statement and the browser simply shows a
> blank page with a couple of warnings about changing the salt and cipherSeed.

 Read this aloud "You can not send output to the webpage and then redirect."

AD


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pokerphp  
View profile  
 More options Mar 20 2012, 6:15 am
From: pokerphp <blog...@holdem.lt>
Date: Tue, 20 Mar 2012 03:15:54 -0700 (PDT)
Local: Tues, Mar 20 2012 6:15 am
Subject: Re: How do I redirect?

class TestsController extends AppController
{
  public function index()
  {
  }

  public function change()
  {
    $this->redirect(array('controller' => 'tests', 'action' => 'index'));
  }

}

then create the file /View/Tests/index.ctp containing "in the index" or
whatever output you like.

open http://host/tests/
to see if it shows what's in your index.ctp file (if not, then this is your
problem, not the redirection).

if index works, now open http://host/tests/change/ and it will redirect you.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pokerphp  
View profile  
 More options Mar 20 2012, 6:23 am
From: pokerphp <blog...@holdem.lt>
Date: Tue, 20 Mar 2012 03:23:29 -0700 (PDT)
Local: Tues, Mar 20 2012 6:23 am
Subject: Re: How do I redirect?

> Also never do any output from the controller. If you still want to make it
>>>> nasty use something like

  public function index()  {    $nasty = 'in the index';    $this->set('nasty', $nasty);  }

then in the View/Tests/index.ctp
<?php
  print $nasty;
?>

this will be way better than printing directly from the controller.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
euromark  
View profile  
 More options Mar 20 2012, 8:43 am
From: euromark <dereurom...@googlemail.com>
Date: Tue, 20 Mar 2012 05:43:35 -0700 (PDT)
Local: Tues, Mar 20 2012 8:43 am
Subject: Re: How do I redirect?

i sure hope its not the same guy:
http://stackoverflow.com/questions/9763280/cakephp-2-0-upgrade-shell-...

same time, same crazy idea

guys. if you want to crappy debug here, use DIE();

    die('before redirect');
    $this->redirect(array('controller' => 'test', 'action' => 'index'));
    die('after redirect'); // totally nonsense, because it will NEVER reach this point

echo creates problems - and doesnt solve any!

if you want to NOT crappy debug with redirects, use something else, like
log():

    $this->log('some log entry', 'test');

and look into /tmp/logs/test.log

Am Dienstag, 20. März 2012 11:23:29 UTC+1 schrieb pokerphp:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
glevine  
View profile  
 More options Mar 20 2012, 12:49 pm
From: glevine <levine.g...@gmail.com>
Date: Tue, 20 Mar 2012 09:49:32 -0700 (PDT)
Local: Tues, Mar 20 2012 12:49 pm
Subject: Re: How do I redirect?

AD7six,

Initially, I had a print statement before the redirect left over from when
I was tracing the code path down to the header() call. After commenting out
all print statements except the one in index(), I still don't successfully
redirect. That print statement shouldn't be called until after the redirect
has occurred. So unless you can explain why any output from index() would
have an affect on the redirect, I think we can do without the condescending
tone. Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
glevine  
View profile  
 More options Mar 20 2012, 12:52 pm
From: glevine <levine.g...@gmail.com>
Date: Tue, 20 Mar 2012 09:52:06 -0700 (PDT)
Local: Tues, Mar 20 2012 12:52 pm
Subject: Re: How do I redirect?

Fair enough. My example was only to show that I was having trouble with
reaching certain points in the code. I didn't want to write a lot of code
for an example that didn't need to be overly complex to get the point
across.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
glevine  
View profile  
 More options Mar 20 2012, 12:58 pm
From: glevine <levine.g...@gmail.com>
Date: Tue, 20 Mar 2012 09:58:04 -0700 (PDT)
Local: Tues, Mar 20 2012 12:58 pm
Subject: Re: How do I redirect?

euromark,

No that stackoverflow post is not me. As I said previously, I'm not
actually debugging with the code that I wrote above. I just posted an
extremely rudimentary and flawed example to see if there was something
outside of common sense that I was missing. The code I'm debugging doesn't
print anywhere inside the method where the redirect happens. What's in
index() shouldn't have any affect. If you must know, I have nothing in my
index() method at the moment. I just want to see the url change, which it's
not.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
glevine  
View profile  
 More options Mar 20 2012, 1:15 pm
From: glevine <levine.g...@gmail.com>
Date: Tue, 20 Mar 2012 10:15:44 -0700 (PDT)
Local: Tues, Mar 20 2012 1:15 pm
Subject: Re: How do I redirect?

In case anyone really cares, it was failing because the debugger was
outputting warnings about changing the salt and cipherSeed configs. So that
was the output that was being printed before the redirect which was giving
me issues. Obviously I should have just taken care to do that sooner, but I
was being lazy and assuming that problem was with my code and not the
CakePHP library. Live 'n' learn.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
euromark  
View profile  
 More options Mar 20 2012, 7:09 pm
From: euromark <dereurom...@googlemail.com>
Date: Tue, 20 Mar 2012 16:09:14 -0700 (PDT)
Local: Tues, Mar 20 2012 7:09 pm
Subject: Re: How do I redirect?

and for more details on the subject see
http://kb2.adobe.com/community/publishing/505/cpsid_50572.html

Am Dienstag, 20. März 2012 18:15:44 UTC+1 schrieb glevine:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
AD7six  
View profile  
 More options Mar 21 2012, 5:47 am
From: AD7six <andydawso...@gmail.com>
Date: Wed, 21 Mar 2012 02:47:20 -0700 (PDT)
Local: Wed, Mar 21 2012 5:47 am
Subject: Re: How do I redirect?

On Tuesday, 20 March 2012 18:15:44 UTC+1, glevine wrote:

> In case anyone really cares, it was failing because the debugger was
> outputting warnings about changing the salt and cipherSeed configs.

The point of my message was to highlight that's the case - and that the
first reply you received (2 hours after you posted originally) should also
have led you to the same conclusion. As such, the rest of the thread is
mostly noise.

Evidently though the meaning of my message was not understood, the
intention was literally to get you to re-read that first reply.

I'm not actually debugging with the code that I wrote above.


It's a good idea to post slimmed down code, but it has to actually work
unless it's a pseudo-code example. It's a really bad idea to
post fundamentally wrong code that you aren't using and haven't tested - it
will often, as is the case here, lead people to focus on problems with your
example rather than the problem you're actually looking at.

AD


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »