Jump to content

Archived

This topic is now archived and is closed to further replies.

subzerostudio

& replaced with &

Recommended Posts

I have a problem with an oscommerce store, specifically the protx payment module. But that isn't really important.  The problem occurs when an error is passed back to a previous page via a get variable.  All of the & in the string, save for the first one, are replaced with &  Making it impossible (as far as I'm aware) to extract the string or variable from the URL.

Here's the offending code
[code]$payment_error_return = 'payment_error=' . $this->code . '&error=' . urlencode($error) . '&protx_direct_cc_owner=' . urlencode($HTTP_POST_VARS['protx_direct_cc_owner']) . '&protx_direct_cc_expires_month=' . $HTTP_POST_VARS['protx_direct_cc_expires_month'] . '&protx_direct_cc_expires_year=' . $HTTP_POST_VARS['protx_direct_cc_expires_year'];

tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, $payment_error_return, 'SSL', true, false));[/code]

and the tep_redirect function:
[code]// Redirect to another page or site
  function tep_redirect($url) {
    if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
      if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
        $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
      }
    }

    header('Location: ' . $url);

    tep_exit();
  }[/code]

Thanks

Mike

Share this post


Link to post
Share on other sites
an example of a URL i'm getting

[code]
checkout_payment.php?payment_error=protx_direct&error=The+credit+card+number+entered+is+invalid.%3Cbr%3EPlease+check+the+number+and+try+again.&protx_direct_cc_owner=Mike+Collins&protx_direct_cc_expires_month=01&protx_direct_cc_expires_year=09&osCsid=c90bf25c5c0bc13cc6466fc916a0c440
[/code]

Share this post


Link to post
Share on other sites
Just use the function urldecode() on the returned string before processing it.

Ken

Share this post


Link to post
Share on other sites
excuse my ignorance.. but i've been trying for a while now and am unable to do it..

Latest attempt is:

[code]<?php echo urldecode($_GET['error']); ?>[/code]

But this doesn't work...

Share this post


Link to post
Share on other sites
What do you mean by "But this doesn't work..."?

What doesn't work? What were you expecting? Please post the relevant piece of code that is causing the problems.

Ken

Share this post


Link to post
Share on other sites
Hi Ken

Code is posted above in the original post.

Basically what I am trying to do is either:

extract  the 'error' variable from the following URL that is passed
[code]checkout_payment.php?payment_error=protx_direct&amp;error=The+credit+card+number+entered+is+invalid.%3Cbr%3EPlease+check+the+number+and+try+again.&amp;protx_direct_cc_owner=Mike+Collins&amp;protx_direct_cc_expires_month=01&amp;protx_direct_cc_expires_year=09&amp;osCsid=c90bf25c5c0bc13cc6466fc916a0c440[/code]

or

somehow rewrite the url so that & is not written as &amp;

e.g.
[code]checkout_payment.php?payment_error=protx_direct&error=The+credit+card+number+entered+is+invalid.%3Cbr%3EPlease+check+the+number+and+try+again.&protx_direct_cc_owner=Mike+Collins&protx_direct_cc_expires_month=01&protx_direct_cc_expires_year=09&osCsid=c90bf25c5c0bc13cc6466fc916a0c440[/code]


The url given is achieved not via a href link, but rather a redirect using header()

It may have something to do with the specific version of PHP on my server.. As the exact same code doesn't have the same problems on other sites that I've done.  It's running PHP 4.4.2

Thanks again,

Mike

Share this post


Link to post
Share on other sites
You still haven't posted the code that is rellevant to the error. Post the block of code that causes the error.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.