Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How to add a form to a template Rate Topic   - - - - -

 
  • jeffshead
  • Member
  • Members
  • Join Date: 15-May 08
  • 121 posts

Posted 02 October 2012 - 07:43 PM #1

I'm successfully using a hook to override the add to cart buttons so different buttons are automatically used on the product page depending on certain criteria. That's working fine with no problems.

What I want to do now, is use a form button so it posts data to a particular page.

I tried using the form below to replace the button but it does not work:
<form action="http://www.mysite.com/myPage.php" method="post" enctype="multipart/form-data" name="myPage">
  <input name="myData" type="hidden" value="{$product.data}" />
  <input name="dataButton" type="submit" value="submit" />
</form>

It seems CS-Cart takes over the action and/or post so it does not work like a regular form. When I hover over the submit button, it shows index.php in the title when it should be the page I have specified in the action. When the form button is clicked, it looks like it submits to index.php instead of the page I have specified in the form action.

I tried get and got the same results.

How can I post data from this template to myPage.php when the button is clicked?
CS-Cart 4.6.3 SP1

 
  • jeffshead
  • Member
  • Members
  • Join Date: 15-May 08
  • 121 posts

Posted 02 October 2012 - 11:09 PM #2

Must of had a brain f@rt...

I forgot about passing variables in the URL. That works just fine since the data is not sensitive so I don't need to use a form after all. :rolleyes:
CS-Cart 4.6.3 SP1

 
  • jeffshead
  • Member
  • Members
  • Join Date: 15-May 08
  • 121 posts

Posted 03 October 2012 - 04:57 AM #3

Spoke to soon. Passing variables in the URL works on some URL's but not others.

How can I pass URL's that contain "&" ?

What I have is a link on a product page. The link contains a variable for an external URL. When a customer clicks on the link, they are redirected to a page on my site that includes an iframe. The URL for the external site is passed to this page and the external page is opened in the iframe. It works on any URL that does not contain any "&".

Here is the link with the variable:
<a class="Button" href="/Page.php?URL={$product.url}"></a>

Here's an example that fails:
<a class="Button" href="/Page.php?URL=http://www.whatever-site.com/r.cfm?b=12c45&u=670475&m=3826&urllink="></a>

Replacing the "&" with "&amp;" or "%26" does not work.
CS-Cart 4.6.3 SP1

 
  • jeffshead
  • Member
  • Members
  • Join Date: 15-May 08
  • 121 posts

Posted 03 October 2012 - 05:39 AM #4

I figured it out.

This works:
<a class="Button" href="/Page.php?URL={$product.url|escape:"url"}"></a>

CS-Cart 4.6.3 SP1

 
  • jeffshead
  • Member
  • Members
  • Join Date: 15-May 08
  • 121 posts

Posted 08 November 2012 - 08:13 PM #5

I do need to use a form to post some data. Can someone please read the first post in this thread and tell me how I can get this working?

CS-Cart 4.6.3 SP1