I have a page with a form, this form redirects the user to another page, however the user can only access this page if the form has been subimitted, for that I check if there's any token.
I have the following piece of code in my viw file:
if( JRequest::checkToken() ==false){
echo "The form was not submitted";
}else{
// Display the view
parent::display($tpl);
}
// Set the document
$this->setDocument();
This partially works because it indeed verifies whether the user submitted the form or not; however, when the user submits the form for the first time, it does not recoginse the token (because it displays the error message "The form was not submitted") but if I come back to the form page and submit the form again, it works fine.
My question is:
What is the proper way to check the form submission using JRequest::checkToken()
or any similar method and where would be the best way to place the function? Would it be in the view file?