PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 22, 2022

[FIXED] CakePHP redirect with form parameter

 February 22, 2022     cakephp-3.0     No comments   

Issue

In CakePHP 3.1 I am redirecting to login page after a database update and I want to pass back the email so that form input is already populated.

I can do it the standard way with using the controller and action in the redirect.

Instead I am using just a url string

return $this->redirect('/login',['?' => ['email' => $email]]);

This gives me the error Unknown status code


Solution

The redirect method expects a status code as the second parameter. You will need to provide and array-based URL as the first parameter or append the query var to the current string.

return $this->redirect('/login?email=' . $email);

return $this->redirect([ 'controller' => 'Users', 'action' => 'login', '?' => [ 'email' => $email ] ]);



Answered By - cjquinn
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing