PHP method to get query parameters sent to script
P粉459578805
P粉459578805 2024-03-29 13:45:30
0
1
435

A friend contracted with some WordPress agency to create a web page that creates a custom URL based on the input data the user enters on a form to redirect to a 3rd party API that displays some car rental data, this WordPress is using elementor Completed plugin, the problem is, when the redirect query parameter separator is encoded as html entity i.e. the url must be something like www.site.com/?value1=value1&value2=value2&value3=value3 but the plugin is converting url changed to www.site .com/?value1=value1&value2=value2&value3=value3 & is being encoded to & for this institution Didn't get the job done, didn't want to and couldn't fix this, he asked me if he could fix it, I'm not a WordPress developer so it was difficult for me, in other posts I was told that I could create a custom decoder php file to handle this on the root folder of the WordPress installation, instead of redirecting the form to a 3rd party API I can redirect to a custom decoder on the site domain and fix the url and then redirect to the 3rd party API but I can't get the url sent by the form in the php script I now have this code

<?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();
?>

I also saw that $_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 do I do that? The form will now redirect to www.misytedomain.com/custom-decoder/decoder.php/?value1=value1&value2=value2&value3=value3 This is what I have to use to build the send to the API url of url. < /p>

edit:

Sorry if I missed the explanation, for example the form now redirects to www.site.com/?value1=value1&value2=value2&value3=value3 but this doesn't work on the API, So I will instead redirect that URL to a location on my domain where the php file looks like www.mysitedomain.com/custom-decoder/decoder.php I think I can add the error Query parameters, such as www.mysitedomain.com/custom-decoder /decoder.php/?value1=value1&value2=value2&value3=value3 Use wrong parameters, use PHP logic to fix them, and finally use them correctly The parameters redirect to the API, for example www.site.com/?value1=value1&value2=value2&value3= value3 www.site.com is the api, www.mysitedomain.com is my WordPress domain

P粉459578805
P粉459578805

reply all(1)
P粉136356287

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template