Jump to content

Javascript form path error


Guest littlewild

Recommended Posts

Guest littlewild

Hi all, I have successfully installed Cube Cart version 3 and have managed to set up a few dummy products to play with.

However there is a big problem with my setup. The JavaScript function submitDoc is sending the forms to the wrong places which mess up the site pretty badly.

My site's URL is "http://www.mysite.com" and CubeCart is installed in the /cube folder. Whenever I click on the Add to basket link, which invokes java script:submitDoc('addtobasket'); the URL becomes messed up.

Instead of going to

"http://www.mysite.com/cube/index.php/?act=viewProd&productId=1"

it is going to

"http://www.mysite.com/cube/index.php/cube/index.php?act=viewProd&productId=1"

Note the difference in bold. There is an additional /cube/index.php in the path, which results in a formatting error in the page, messing up the layouts.

I have done some searching and Googling but am unable to find any way to fix this problem. I have tried changing the 'rootRel' in the global.inc.php but that doesn't seem to fix the problem.

Btw, my web host is GoDaddy.

Any help will be much appreciated. Thanks in advance!

Link to comment
Share on other sites

Guest littlewild

.... ok I am an idiot.

Apparently it is not the Javascript issue. I just took a look at the code and realized that it is only doing a simple redirection. The issue lies with the form that has its action attribute set wrongly.

Right now it is

<form action="/cube/index.php/cube/index.php?act=viewProd&amp;productId=3" method="post" name="addtobasket" target="_self" id="addtobasket" >

when it really should be

<form action="/cube/index.php?act=viewProd&amp;productId=3" method="post" name="addtobasket" target="_self" id="addtobasket" >

Any one knows how to fix this path issue?

Link to comment
Share on other sites

Guest littlewild

Ok I dug a little deeper and I found that the problem lies with the currentpage() function found in functions.inc.php

For some reason or other it is rendering the current page URL with additional /folder and php file name...

Any insight into this will be much appreciated!

Link to comment
Share on other sites

Guest littlewild

Hmm I think I am onto something.

Further studying of the code and some tweaking reveals that the PHP array $_SERVER is returning odd values...

The PHP Array $_SERVER['PHP_SELF'] is returning a duplicated path, which is causing all of the errors.

Instead of returning just /cube/index.php it is returning /cube/index.php/cube/index.php

Hmm interesting.

I did a little hacking and changed the $_SERVER['PHP_SELF'] to $_SERVER['SCRIPT_NAME'] and the weird pathing issue disappeared...

Well, I guess I fixed the problem myself. If anyone else encounters the same problem, maybe this will help them.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...