Jump to content

& replaced with &


subzerostudio

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
Link to comment
https://forums.phpfreaks.com/topic/20410-replaced-with-amp/
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]
Link to comment
https://forums.phpfreaks.com/topic/20410-replaced-with-amp/#findComment-89916
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&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]

or

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

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
Link to comment
https://forums.phpfreaks.com/topic/20410-replaced-with-amp/#findComment-89958
Share on other sites

Archived

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

×
×
  • Create New...

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.