ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

redirect with method = "POST"

tshirley 25 Aug, 2019
Hi,

I have a need to redirect from a form with method = "POST", and I think the Redirect Action only uses "GET".

I solved this a couple of years ago by inserting the following html form in an html action:

<?php
echo '<form action="https://gotohere.com" method="POST">';
echo '<input type="hidden" name="Email" value=' + $form->data['email'] + '>';
echo '<input type="hidden" name="Id" value=' + $form->data['id'] + '>';
echo '<input type="hidden" name="auth" value=' + $form->data['auth'] + '>';
echo '<input type="submit">';
echo '</form>';
?>

which did the job at the time, but now when I try it in CF6 this gives me an Error 403.

I can't see what I am doing wrong, the form above used to work fine and still does if it is outside the CF6 environment. Unfortunately I need to do this from inside a CF6 form.

Can anyone suggest what is wrong, and a solution?

Thanks

Tim
tshirley 25 Aug, 2019
of course, after changing $form->data to $this->data🙂
tshirley 25 Aug, 2019
OK, more info.. I tried the same thing with a cURL:

$data = http_build_query( array('id' => $this->data['id'],
'email' => $this->data['email'],
'auth' =>$this->data['auth'] ));


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://gohere.com');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$r = curl_exec($ch);
curl_close($ch);

and still got a 403 error when saving the form. So then I added the lines one at a time, saving on each line, and it was the line

$r = curl_exec($ch);

which gave a 403 on form full save. If I do "Quick Save", the save just hangs indefinitely. I don't understand why CF6 would give that error on saving a form, but it obviously is doing something with the curl_exec, and also with the previous iteration of this as well.
healyhatman 26 Aug, 2019
I don't understand what you're trying to do, but it SEEMS like all you want is to have your form submit somewhere else? So just set your form to "custom", use a Form Area, and manually set the form action URL.
tshirley 26 Aug, 2019
For various reasons (not of my making), I need the CF6 form to redirect but with a "method=POST" and a few parameters - not the default GET that happens with the Redirect action. It is the method=POST that is causing the problem.

Back several versions (of CF, PHP and Joomla) , I could do this by embedding the html form from my first post above, into an html action. Today, that same solution generates a 403 error when saving the form.

So my redirect url from the form area needs to look something like 'https://gotohere.com/POST?p1=data1&p2=data2'

Thanks as always for your help.
healyhatman 26 Aug, 2019
You just copy pasted your original question but here you go

https://stackoverflow.com/a/5576700/5907930

You can't just redirect to a post method that's not how it works.
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com