Hi Guys, I need some help to understand my problem.
I have a form that send some info (by post) to a third party API by CURL. The controller action that does that has a redirect in both case fail or success.
My problem is that if I click twice or more the submit button, than I get two or more successful calls to that API and only after that the action is doing the redirect to the success page.
How can I prevent that on server side? I’ve tried using sessions but still doesn’t work.
The code is like this:
...
try
{
if ($new_user->validate())
{
if( Yii::app()->theExternalApi->pay($new_user) )
$this->redirect(array('controller/success'));
}
}
catch()...
// session protected code version (not working also):
...
try
{
if ($new_user->validate() !isset(Yii::app()->session['doubleclick']))
{
Yii::app()->theExternalApi->pay($new_user);
Yii::app()->session['doubleclick'] = true;
}
}
catch()...