Error 403 on submit forms


#1

When I try to submit a form on the server I get the error below:
On localhost works fine.

Please enable cookies.
One more step
Please complete the security check to access forms.hubspot.com
Why do I have to complete a CAPTCHA?
Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

What can I do to prevent this in the future?
If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

Cloudflare Ray ID: 41d032746b4e4a84 • Your IP: 177.185.194.115 • Performance & security by Cloudflare

My code:
[quote="Diogenes_Konrad_Gotz, post:1, topic:9916, full:true"]
When I try to submit a form on the server I get the error below:
On localhost works fine.

Please enable cookies.
One more step
Please complete the security check to access forms.hubspot.com
Why do I have to complete a CAPTCHA?
Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

What can I do to prevent this in the future?
If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

Cloudflare Ray ID: 41d032746b4e4a84 • Your IP: 177.185.194.115 • Performance & security by Cloudflare

My code:
public function SubmitHubspotForm(Request $request)
{
$rules = [
'firstname' => 'required|max:255',
'lastname' => 'required|max:255',
'email' => 'required|email',
'phone' => 'required|max:20',
'message' => 'required|max:1000',
];

    $this->validate($request, $rules);

    $hs_context = array(
        'hutk'      => $_COOKIE['hubspotutk'],
        'ipAddress' => $_SERVER['REMOTE_ADDR'],
        'pageUrl'   => 'https://www.gotz.com.br',
        'pageName'  => 'Formulário de contato'
    );

    $str_post = "firstname=" . urlencode($request->firstname)
        . "&lastname=" . urlencode($request->lastname)
        . "&email=" . urlencode($request->email)
        . "&phone=" . urlencode($request->phone)
        . "&message=" . urlencode($request->message)
        . "&hs_context=" . urlencode(json_encode($hs_context));

    $endpoint = 'https://forms.hubspot.com/uploads/form/v2/4504469/50ab4bf4-6789-4cb5-a28b-b251643d9ec5';

    $ch = @curl_init();
    @curl_setopt($ch, CURLOPT_POST, true);
    @curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post);
    @curl_setopt($ch, CURLOPT_URL, $endpoint);
    @curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/x-www-form-urlencoded'
    ));
    @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = @curl_exec($ch);
    $status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
    @curl_close($ch);

    if ($status_code == 204) {
        $return = array(
            'status'  => 'success',
            'message' => 'Sua mensagem foi enviada com sucesso!',
        );
    } else {
        $return = array(
            'status'  => 'error',
            'message' => 'Ocorreu algum erro ao processar o formulário',
        );
    }

    return \Response::json($return);
}

[/quote]


#2

Hi @Diogenes_Konrad_Gotz,

That error comes from our service provider's automatic security features. It can be triggered if your IP address has been blocked or if you're making requests to quickly. The following article has some more details on what these errors mean: