subzerostudio Posted September 11, 2006 Share Posted September 11, 2006 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]ThanksMike Quote Link to comment Share on other sites More sharing options...
subzerostudio Posted September 11, 2006 Author Share Posted September 11, 2006 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] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 11, 2006 Share Posted September 11, 2006 Just use the function urldecode() on the returned string before processing it.Ken Quote Link to comment Share on other sites More sharing options...
subzerostudio Posted September 11, 2006 Author Share Posted September 11, 2006 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... Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 11, 2006 Share Posted September 11, 2006 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 Quote Link to comment Share on other sites More sharing options...
subzerostudio Posted September 11, 2006 Author Share Posted September 11, 2006 Hi KenCode 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]orsomehow 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.2Thanks again,Mike Quote Link to comment Share on other sites More sharing options...
subzerostudio Posted September 12, 2006 Author Share Posted September 12, 2006 Still looking for a solution to this. So if anyone has any advice, that'd be great ;) Quote Link to comment Share on other sites More sharing options...
Jenk Posted September 12, 2006 Share Posted September 12, 2006 You still haven't posted the code that is rellevant to the error. Post the block of code that causes the error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.