简体   繁体   中英

PHP - How to get query params sent to script

A friend contracted some wordpress agency to create a webpage that based on input data entered by user on a form create a custom URL to redirect to a third party API that shows some data to rent a car, this wordpress is done with elementor plugin and the problem is that when redirecting the query params separators are being encoded as html entities ie the url must be something like www.site.com/?value1=value1&value2=value2&value3=value3 but the plugin is changing the url to www.site.com/?value1=value1&value2=value2&value3=value3 the & is being encoded to & , this agency left the work unfinished and don't want and also can't fix this, he asked me if I can fix it, I am not a wordpress developer so have been difficult for me, in other post someone said me that I can create a custom decoder php file to handle this on the rootfolder of the wordpress installation and instead of redirecting the form to the third party API I can redirect to the custom decoder on the site domain and fix the url to then redirect to the third party API but I can't get the url sent by the form in the php script I have this code right now

<?php
ob_start();

$API_BASE_URL="www.site.com/";

$bad_url={here must be the url sent by the form};

//here is fixed the url
$good_url=html_entity_decode($bad_url);

//concatenation of API_BASE_URL and goodurl
$redirect_url=&API_BASE_URL.$good_url

//redirects to fixed url
header('Location: '.$redirect_url);

exit();
?>

Also i saw that the $_SERVER['HTTP_REFERER'] can be used to get this url but this is not reliable, so I need another way to get the url of the form, how can I do this? the form will now redirect to www.misytedomain.com/custom-decoder/decoder.php/?value1=value1&amp;value2=value2&amp;value3=value3 that is the url I must use to build the url to send to the API.

EDIT:

srry if I am missexplaining for example, the form redirects right now to www.site.com/?value1=value1&amp;value2=value2&amp;value3=value3 but this won't work on the API so I will instead of redirec to that URL redirect to the location on my domain where the php file is somethin like www.mysitedomain.com/custom-decoder/decoder.php I thought that I could add the wrong query params like www.mysitedomain.com/custom-decoder/decoder.php/?value1=value1&amp;value2=value2&amp;value3=value3 take this wrong params, fix with the php logic and finally redirect to the API with correct params like www.site.com/?value1=value1&value2=value2&value3=value3 www.site.com is the api and www.mysitedomain.com is my wordpress domain

Configure a redirect from plugin to your own PHP script (don't forget to add your broken query parameters) and then access wrong query parameters in $_SERVER['REQUEST_URI']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM