Hello friends, I am trying to use controller for user signup and for testing and developing purpos, I am using get method so I can see json encoded reposne in my webpage. Now the problem is that my controller is getting only one get variable which is "key" and I want it to verify with csrf session. After then when I try to catch all other details and set them to local variable, it is not loading the page and showing me error connection was reset on my browser.
public function signupAction()
{
$this->view->disable();
//Create a request instance
$request = new Phalcon\Http\Request();
if($request->getQuery("key") == $this->session->get("CSRF")){
$key = $request->getQuery("key");
$email = ($request->getQuery("email")) ? $request->getQuery("email") : '';
$uname = ($request->getQuery("uname")) ? $request->getQuery("uname") : '';
$pass = ($request->getQuery("pass")) ? $this->security->hash($request->getQuery("pass")) : '';
if(!empty($key) && !empty($email) && !empty($uname) && !empty($pass)){
$msg = array('hi'=>'hello');
}else{
$msg = array('error' => 'true', 'message' => 'Cachable error', 'details' => 'Please enter all details.');
}
}else{
$msg = array('error' => 'true', 'message' => 'Token miss match');
}
$response = new \Phalcon\Http\Response();
$response->setContent(json_encode($msg));
echo($response->getContent());
}
These are current codes. If I try to access url localhost/signup?key=123 I am getting error on my page that all details are required. But if I try to access localhost/signup?key=123&uname=abc&[email protected]&pass=123456 my broser is showing me error of connection reset.
First I tried to catch variabled and save them in local vars as
$email = $request->getQuery("email");
and it didn't work either. So can anyone tell me the reason why it is resetting the connection? It worked for once atleast.