history pushstate fetch the url parameter using PHP - php

im trying to fetch the url parameter i pass to my current url, and i already use PHP get, post, request function to fetch, but nothing happened?
look at my code:
PHP:
echo $_POST['x'];// current page
echo $_REQUEST['x'];// current page
echo $_GET['x'];// current page
jquery:
history.pushState({}, '', 'daone.php?x=1'); // current page

Related

Ajax request - determine current wordpress page in functions.php

I've tried to determine the current page in functions.php with an if (is_home()) function, because I only want to run the specific ajax request on my homepage, but it always returns false and if I request the current URI, it says /wp-admin/admin-ajax.php/wp-admin/admin-ajax.php, the URI I actually request in my JS Ajax function.
So how can I only request my current page instead of the Ajax request?
Thanks for any help!
In the javascript
var pathname = window.location.pathname;
Then you can pass it with the rest of your data to the php function.

how to get passed in function from page url php

I am trying to pass the id to another page so it can be deleted when the link is pressed. the Id is displaying in the url but I am having trouble, getting hold of the id, I have tried: to use the pars url but it is not working.
parse url
echo parse_url( $_SERVER['REQUEST_URI'], PHP_URL_QUERY);
link
<p>Delete</p
It is because your URL needs to be corrected to add a query string, starting with a ? and an identifier
<a href="<?php echo 'example.php/?foo='.$item->getproductid(); ?>">
Now you can either parse the URL (not necessary and unnecessarily complex for this action) or get the value from the GET array:
$_GET['foo']; // is the id in $item->getproductid()

Passing the URL of a page to a PHP POST call

I need to pass the URL of a page to a PHP POST function which will return a document. I was wondering if it is possible to pass in the URL via a function or will it have to be stored in a variable? Or is it even possible to do this? I have this function to retrieve the URL of the previous page:
$(document).ready(function() {
var referrer = document.referrer;
});
And this is the PHP POST method which does not work:
$_POST['http://<THE URL I AM SENDING THE REQUEST TO>&url=<THE URL OF THE PREVIOUS PAGE>'];
I had it set up like:
$_POST['http://<THE URL I AM SENDING THE REQUEST TO>&url=referrer'];
But it would not run. Does anyone know how I can get this to work? Thanks

PHP: obtain the url page that call my page php

I have an HTML page that calls my page php.
I want via php to obtain the URL that calls me.
I have tried $_SERVER['REQUEST_URI']; but it returns me the URL of my page.
$_SERVER['HTTP_REFERER'];
Please note that this value is not 100% sure (it's possible for the client/users to modify it), but it's still what's closest from what you want.

Get the Referer name requested from http_request2 lib symfony1

I have a query, as defined in the title, how to get the getReferer() functionality, when the called page is http_request call.
This url
How to get previous page route in Symfony? will work only when there is a page submit from previous page, then the $request->getReferer(); will get the value, But what if the previous page submit is a ajax call where in i will post only username, and the ajax call will respond with some code.
Requested:
How to Know the previous page URL When it is http_request call
Use getPathInfoArray().
$pathinfo = $request->getPathInfoArray();
$referer = $pathinfo['HTTP_REFERER'];

Categories