General Redneck
General Redneck

Reputation: 1345

How do I pass a URL as a parameter of an URL in Zend Framework?

My question spawns from me sending an email to the user with something like the following:

http://mydomain.net/login/index/dest/%2Finvitation%2Fconfirm%2Fconfirmation_key%2F15116b5e4c61e4111ade679c10b3bf27

As you can see, what I'm trying to do is pass a url as the parameter "dest" so that the login page will know where to redirect after the user logs in. However, I'm presented with the following:

404 Not Found - /login/index/dest//invitation/confirm/confirmation_key/15116b5e4c61e4111ade679c10b3bf27

This is the View I use to create the email:

<p>
<?if($this->invitation->user):?>
<a href='<?=$this->serverUrl($this->baseUrl().$this->url(array(
    'action'=>'index',
    'controller'=>'login',
    'dest'=>$this->url(array(
        'action'=>'confirm',
        'controller'=>'invitation',
        'confirmation_key'=>$this->invitation->confirmation_key
    ))
)));?>'>Log in to confirm this invitation.</a>

//The view continues...

Any idea on how to keep this from translating the URI encoded items to their literal value would be greatly appreciated.

Upvotes: 3

Views: 484

Answers (3)

Jirka Helmich
Jirka Helmich

Reputation: 106

You can also upgrade your link like this:

<a href='<?=$this->serverUrl($this->baseUrl().$this->url(array(
'action'=>'index',
'controller'=>'login',
'dest'=>base64_encode($this->url(array(
    'action'=>'confirm',
    'controller'=>'invitation',
    'confirmation_key'=>$this->invitation->confirmation_key
))))

));?>'>Log in to confirm this invitation.</a>

But on the /login/index, you will need to use the base64_decode() to get the original Not the most pretty solution, but if you are not able to use the simple querystring, this is a way, how to pass a string via URL safely.

http://en.wikipedia.org/wiki/Base64

Upvotes: 0

Itay Moav -Malimovka
Itay Moav -Malimovka

Reputation: 53603

  1. What ChrisR wrote is absolutly the answer
  2. Why wouldn't you just use the $_SERVER['referer']

Upvotes: 1

ChrisR
ChrisR

Reputation: 14447

Can't you just send it over as a simpel GET parameter?

Like http://mydomain.net/login/index/?redirect=/invitation/confirm/confirmation_key/15116b5e4c61e4111ade679c10b3bf27

That's how it's mostly done actually.

Upvotes: 6

Related Questions