user3026704
user3026704

Reputation: 123

query string http%3A%2F%2F turns into http%253A%252F%252

I have a problem with query string symbols.

I'm redirecting user to this link

payment.php?pg_amount=294.91&pg_check_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fcheck.php&pg_description=order+number+%2339&pg_failure_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Ffailure.php&pg_failure_url_method=POST&pg_lifetime=86400&pg_merchant_id=4726&pg_order_id=39&pg_refund_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Frefund.php&pg_request_method=POST&pg_result_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fresult.php&pg_salt=52ed1c15ce83b&pg_site_url=http%3A%2F%2Fofficecorp.ru&pg_success_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fsuccess.php&pg_success_url_method=AUTOPOST&pg_testing_mode=1&pg_user_contact_email=t.muradyan%40platron.ru&pg_user_mail=t.muradyan%40platron.ru&pg_user_phone=79163763072&status_failed=R&status_ok=D&status_revoked=V&pg_sig=134921022b548f00daed122f8249b003

But it turns into

https://www.platron.ru/payment.php?pg_amount=294.91&pg_check_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Fcheck.php&pg_description=order+number+%252339&pg_failure_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Ffailure.php&pg_failure_url_method=POST&pg_lifetime=86400&pg_merchant_id=4726&pg_order_id=39&pg_refund_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Frefund.php&pg_request_method=POST&pg_result_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Fresult.php&pg_salt=52ed1c15ce83b&pg_site_url=http%253A%252F%252Fofficecorp.ru&pg_success_url=http%253A%252F%252Fofficecorp.ru%252Fplatron%252Fsuccess.php&pg_success_url_method=AUTOPOST&pg_testing_mode=1&pg_user_contact_email=t.muradyan%2540platron.ru&pg_user_mail=t.muradyan%2540platron.ru&pg_user_phone=79163763072&status_failed=R&status_ok=D&status_revoked=V&pg_sig=134921022b548f00daed122f8249b003

The letters http%3A%2F%2F turns into http%253A%252F%252.

$strQuery = http_build_query($arrRequest);

$strQuery 

pg_amount=294.91&pg_check_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fcheck.php&pg_description=order+number+%2339&pg_failure_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Ffailure.php&pg_failure_url_method=POST&pg_lifetime=86400&pg_merchant_id=4726&pg_order_id=39&pg_refund_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Frefund.php&pg_request_method=POST&pg_result_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fresult.php&pg_salt=52ed1c15ce83b&pg_site_url=http%3A%2F%2Fofficecorp.ru&pg_success_url=http%3A%2F%2Fofficecorp.ru%2Fplatron%2Fsuccess.php&pg_success_url_method=AUTOPOST&pg_testing_mode=1&pg_user_contact_email=t.muradyan%40platron.ru&pg_user_mail=t.muradyan%40platron.ru&pg_user_phone=79163763072&status_failed=R&status_ok=D&status_revoked=V&pg_sig=134921022b548f00daed122f8249b003

There is a problem with encoding. How to fix it?

Upvotes: 1

Views: 8422

Answers (1)

maja
maja

Reputation: 18034

The reason is, that the %-symbol gets encoded (The hex-value of % is 0x25).

You don't have to manually encode the url, just put your url (with all your special symbols) in the link, and encoding will be done automatically.

The code should look like this afterwards:

$strQuery = http_build_query($arrRequest);

$strQuery 

pg_amount=294.91&pg_check_url=http://officecorp.ru/platron/check.php&pg_description=order number #39&pg_failure_url=http://officecorp.ru/platron/failure.php&pg_failure_url_method=POST&pg_lifetime=86400&pg_merchant_id=4726&pg_order_id=39&pg_refund_url=http://officecorp.ru/platron/refund.php&pg_request_method=POST&pg_result_url=http://officecorp.ru/platron/result.php&pg_salt=52ed1c15ce83b&pg_site_url=http://officecorp.ru&pg_success_url=http://officecorp.ru/platron/success.php&pg_success_url_method=AUTOPOST&pg_testing_mode=1&[email protected]&[email protected]&pg_user_phone=79163763072&status_failed=R&status_ok=D&status_revoked=V&pg_sig=134921022b548f00daed122f8249b003

Upvotes: 1

Related Questions