[Skip to main content](#vessel-content)

#   Redirect issue with reCaptcha v2 error on contact form

##

- **[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")**
- [![lousyfool's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28604.jpg)](/forum/user/28604-lousyfool "View lousyfool's Profile") Topic Author
- [ Offline](/forum/user/28604-lousyfool)

Less More

- Posts: 2143
- Thank you received: 746
-
- [](http://www.inphase.one)
-

5 years 2 months ago -  5 years 2 months ago [\#335569](#335569) by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")  *[Redirect issue with reCaptcha v2 error on contact form](/forum/30-integrations/903172-redirect-issue-with-recaptcha-v2-error-on-contact-form#335569 "-- HikaShop version -- : 4.1.0 -- Joomla version -- : 3.9.something -- PHP version -- : 7.3  Hi,  I'm using the HikaShop reCaptcha v2 plugin only in the contact form... the one that opens after clicking the contact button on product pages. While HikaShop is admittedly not the newest, the reCaptcha plugin is: downloaded it just a few hours ago.  It's generally working fine, until someone has filled in all form fields but forgets to tick the reCaptcha box. In that case the user is being redirected to a weird URL -- actually a &quot;fraction&quot; of the original URL. For example: - Regular contact form URL: domain.com/aaa/bbb/contact/cid-1234 - Redirected in case of reCaptcha error to: domain.com/aaa/bbb The form is still there (with the system error message above), but this weird URL leads to a horrible, unwanted page layout due to all sorts of modules showing that shouldn't be there. (I could eventually restructure numerous module assignments, but neither will it be &quot;fun&quot;, nor should it be necessary.) I see in the &#95;checkCaptcha function in recaptcha2.php a redirect to @$&#95;SERVER&#91;'HTTP&#95;REFERER'), but that doesn't seem to be what's happening. How to fix?  Thanks!")* was created by *[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")*

-- HikaShop version -- : 4.1.0
-- Joomla version -- : 3.9.something
-- PHP version -- : 7.3

Hi,

I'm using the HikaShop reCaptcha v2 plugin only in the contact form... the one that opens after clicking the contact button on product pages.
While HikaShop is admittedly not the newest, the reCaptcha plugin is: downloaded it just a few hours ago.

It's generally working fine, until someone has filled in all form fields but forgets to tick the reCaptcha box.
In that case the user is being redirected to a weird URL -- actually a "fraction" of the original URL. For example:
- Regular contact form URL: domain.com/aaa/bbb/contact/cid-1234
- Redirected in case of reCaptcha error to: domain.com/aaa/bbb
The form is still there (with the system error message above), but this weird URL leads to a horrible, unwanted page layout due to all sorts of modules showing that shouldn't be there. (I could eventually restructure numerous module assignments, but neither will it be "fun", nor should it be necessary.)
I see in the _checkCaptcha function in recaptcha2.php a redirect to @$_SERVER['HTTP_REFERER'), but that doesn't seem to be what's happening. How to fix?

Thanks!

---

Need help with customisations of layouts, style or other site development? [ PM me!](/component/uddeim/?task=new)
(Don't forget to turn on [ "E-mail notification of new messages"](/component/uddeim/?task=settings))

Last edit: 5 years 2 months ago by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile"). Reason: Version numbers. Sorry sorry, getting confused with sites...

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMwLWludGVncmF0aW9ucy85MDMxNzItcmVkaXJlY3QtaXNzdWUtd2l0aC1yZWNhcHRjaGEtdjItZXJyb3Itb24tY29udGFjdC1mb3JtP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")**
- [![lousyfool's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28604.jpg)](/forum/user/28604-lousyfool "View lousyfool's Profile") Topic Author
- [ Offline](/forum/user/28604-lousyfool)

Less More

- Posts: 2143
- Thank you received: 746
-
- [](http://www.inphase.one)
-

5 years 2 months ago [\#335572](#335572) by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")  Replied by *[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")* on topic *[Redirect issue with reCaptcha v2 error on contact form](/forum/30-integrations/903172-redirect-issue-with-recaptcha-v2-error-on-contact-form#335572 "-- HikaShop version -- : 4.1.0 -- Joomla version -- : 3.9.something -- PHP version -- : 7.3  Hi,  I'm using the HikaShop reCaptcha v2 plugin only in the contact form... the one that opens after clicking the contact button on product pages. While HikaShop is admittedly not the newest, the reCaptcha plugin is: downloaded it just a few hours ago.  It's generally working fine, until someone has filled in all form fields but forgets to tick the reCaptcha box. In that case the user is being redirected to a weird URL -- actually a &quot;fraction&quot; of the original URL. For example: - Regular contact form URL: domain.com/aaa/bbb/contact/cid-1234 - Redirected in case of reCaptcha error to: domain.com/aaa/bbb The form is still there (with the system error message above), but this weird URL leads to a horrible, unwanted page layout due to all sorts of modules showing that shouldn't be there. (I could eventually restructure numerous module assignments, but neither will it be &quot;fun&quot;, nor should it be necessary.) I see in the &#95;checkCaptcha function in recaptcha2.php a redirect to @$&#95;SERVER&#91;'HTTP&#95;REFERER'), but that doesn't seem to be what's happening. How to fix?  Thanks!")*

Ooooh... had not tried this, yet: when successfully sending a request via the form, it's redirecting to that weird fractional URL as well.

I hope there's an easy way to change it.

---

Need help with customisations of layouts, style or other site development? [ PM me!](/component/uddeim/?task=new)
(Don't forget to turn on [ "E-mail notification of new messages"](/component/uddeim/?task=settings))

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMwLWludGVncmF0aW9ucy85MDMxNzItcmVkaXJlY3QtaXNzdWUtd2l0aC1yZWNhcHRjaGEtdjItZXJyb3Itb24tY29udGFjdC1mb3JtP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

5 years 2 months ago [\#335573](#335573) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Redirect issue with reCaptcha v2 error on contact form](/forum/30-integrations/903172-redirect-issue-with-recaptcha-v2-error-on-contact-form#335573 "-- HikaShop version -- : 4.1.0 -- Joomla version -- : 3.9.something -- PHP version -- : 7.3  Hi,  I'm using the HikaShop reCaptcha v2 plugin only in the contact form... the one that opens after clicking the contact button on product pages. While HikaShop is admittedly not the newest, the reCaptcha plugin is: downloaded it just a few hours ago.  It's generally working fine, until someone has filled in all form fields but forgets to tick the reCaptcha box. In that case the user is being redirected to a weird URL -- actually a &quot;fraction&quot; of the original URL. For example: - Regular contact form URL: domain.com/aaa/bbb/contact/cid-1234 - Redirected in case of reCaptcha error to: domain.com/aaa/bbb The form is still there (with the system error message above), but this weird URL leads to a horrible, unwanted page layout due to all sorts of modules showing that shouldn't be there. (I could eventually restructure numerous module assignments, but neither will it be &quot;fun&quot;, nor should it be necessary.) I see in the &#95;checkCaptcha function in recaptcha2.php a redirect to @$&#95;SERVER&#91;'HTTP&#95;REFERER'), but that doesn't seem to be what's happening. How to fix?  Thanks!")*

Hi,

The Code:

@$_SERVER['HTTP_REFERER']

in the recaptcha2.php file is not being used as the _checkCaptcha function is called with the $redirect parameter being false in the onBeforeSendContactRequest function triggered by the product controller's send_email function.
In the case of HikaShop's contact form, when the captcha is invalid, the send_email task will just as for the display of the form on the redirected page.
I think what's missing is adding the current Itemid to the URL of the contact form in order to stay on the same menu item and thus not loose the link with the modules.
To do that, add the code: Code:

&lt;?php global $Itemid; $this-&gt;url_itemid=''; if(!empty($Itemid)){ $this-&gt;url_itemid='&amp;Itemid='.$Itemid; } ?&gt;

at the beginning of the product / contact.php view file via the menu Display&gt;Views.
And then change the line: Code:

&lt;form action="&lt;?php echo hikashop_completeLink('product'); ?&gt;" id="hikashop_contact_form" name="hikashop_contact_form" method="post" onsubmit="return checkFields();"&gt;

to: Code:

&lt;form action="&lt;?php echo hikashop_completeLink('product&amp;task=contact&amp;cid='.hikaInput::get()-&gt;getInt('cid').$this-&gt;url_itemid); ?&gt;" id="hikashop_contact_form" name="hikashop_contact_form" method="post" onsubmit="return checkFields();"&gt;

there.
It should then work like you want.

The following user(s) said Thank You: [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMwLWludGVncmF0aW9ucy85MDMxNzItcmVkaXJlY3QtaXNzdWUtd2l0aC1yZWNhcHRjaGEtdjItZXJyb3Itb24tY29udGFjdC1mb3JtP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")**
- [![lousyfool's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28604.jpg)](/forum/user/28604-lousyfool "View lousyfool's Profile") Topic Author
- [ Offline](/forum/user/28604-lousyfool)

Less More

- Posts: 2143
- Thank you received: 746
-
- [](http://www.inphase.one)
-

5 years 2 months ago [\#335582](#335582) by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")  Replied by *[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")* on topic *[Redirect issue with reCaptcha v2 error on contact form](/forum/30-integrations/903172-redirect-issue-with-recaptcha-v2-error-on-contact-form#335582 "-- HikaShop version -- : 4.1.0 -- Joomla version -- : 3.9.something -- PHP version -- : 7.3  Hi,  I'm using the HikaShop reCaptcha v2 plugin only in the contact form... the one that opens after clicking the contact button on product pages. While HikaShop is admittedly not the newest, the reCaptcha plugin is: downloaded it just a few hours ago.  It's generally working fine, until someone has filled in all form fields but forgets to tick the reCaptcha box. In that case the user is being redirected to a weird URL -- actually a &quot;fraction&quot; of the original URL. For example: - Regular contact form URL: domain.com/aaa/bbb/contact/cid-1234 - Redirected in case of reCaptcha error to: domain.com/aaa/bbb The form is still there (with the system error message above), but this weird URL leads to a horrible, unwanted page layout due to all sorts of modules showing that shouldn't be there. (I could eventually restructure numerous module assignments, but neither will it be &quot;fun&quot;, nor should it be necessary.) I see in the &#95;checkCaptcha function in recaptcha2.php a redirect to @$&#95;SERVER&#91;'HTTP&#95;REFERER'), but that doesn't seem to be what's happening. How to fix?  Thanks!")*

Hi Nicolas,

Ah ok... I've been looking in the wrong place again. Your explanation and especially the solution are greatly appreciated! Excellent -- it does the trick, indeed! Maybe something you want to add to the next version -- I can't be the only one stumbling over it.

Now I can remove my JS which I used for "clean-up" on submission or error.
Some I'll keep, though: checking if a success system message exists (= after successful submission) I'm hiding the form (who'd need it then any longer?!) and showing "back to product" and "continue shopping" (linking to the main category listing) buttons instead below the message. ![B)](/media/kunena/emoticons/9.png "B)")

Many thanks once again!

---

Need help with customisations of layouts, style or other site development? [ PM me!](/component/uddeim/?task=new)
(Don't forget to turn on [ "E-mail notification of new messages"](/component/uddeim/?task=settings))

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMwLWludGVncmF0aW9ucy85MDMxNzItcmVkaXJlY3QtaXNzdWUtd2l0aC1yZWNhcHRjaGEtdjItZXJyb3Itb24tY29udGFjdC1mb3JtP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

5 years 2 months ago [\#335584](#335584) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Redirect issue with reCaptcha v2 error on contact form](/forum/30-integrations/903172-redirect-issue-with-recaptcha-v2-error-on-contact-form#335584 "-- HikaShop version -- : 4.1.0 -- Joomla version -- : 3.9.something -- PHP version -- : 7.3  Hi,  I'm using the HikaShop reCaptcha v2 plugin only in the contact form... the one that opens after clicking the contact button on product pages. While HikaShop is admittedly not the newest, the reCaptcha plugin is: downloaded it just a few hours ago.  It's generally working fine, until someone has filled in all form fields but forgets to tick the reCaptcha box. In that case the user is being redirected to a weird URL -- actually a &quot;fraction&quot; of the original URL. For example: - Regular contact form URL: domain.com/aaa/bbb/contact/cid-1234 - Redirected in case of reCaptcha error to: domain.com/aaa/bbb The form is still there (with the system error message above), but this weird URL leads to a horrible, unwanted page layout due to all sorts of modules showing that shouldn't be there. (I could eventually restructure numerous module assignments, but neither will it be &quot;fun&quot;, nor should it be necessary.) I see in the &#95;checkCaptcha function in recaptcha2.php a redirect to @$&#95;SERVER&#91;'HTTP&#95;REFERER'), but that doesn't seem to be what's happening. How to fix?  Thanks!")*

Hi,

Yes, we'll add a cleaner modification for the next version to fix that.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMwLWludGVncmF0aW9ucy85MDMxNzItcmVkaXJlY3QtaXNzdWUtd2l0aC1yZWNhcHRjaGEtdjItZXJyb3Itb24tY29udGFjdC1mb3JtP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.060 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
