Jump to content


Photo

& replaced with &


  • Please log in to reply
7 replies to this topic

#1 subzerostudio

subzerostudio
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 September 2006 - 05:56 PM

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
$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));

and the tep_redirect function:
// 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();
  }

Thanks

Mike

#2 subzerostudio

subzerostudio
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 September 2006 - 06:08 PM

an example of a URL i'm getting

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


#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 September 2006 - 06:21 PM

Just use the function urldecode() on the returned string before processing it.

Ken

#4 subzerostudio

subzerostudio
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 September 2006 - 07:03 PM

excuse my ignorance.. but i've been trying for a while now and am unable to do it..

Latest attempt is:

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

But this doesn't work...



#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 September 2006 - 07:17 PM

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

#6 subzerostudio

subzerostudio
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 11 September 2006 - 07:49 PM

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
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

or

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

e.g.
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


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

#7 subzerostudio

subzerostudio
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 12 September 2006 - 09:02 AM

Still looking for a solution to this. So if anyone has any advice, that'd be great  ;)

#8 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 12 September 2006 - 10:24 AM

You still haven't posted the code that is rellevant to the error. Post the block of code that causes the error.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users