Obtain actual browser URL in PHP
Get the solution ↓↓↓Solution:
You could pass it up from javascript in your ajax request, usingwindow.location.href
.
Also, it's likely that$_SERVER['HTTP_REFERER']
will contain the browser's current location.
Answer
Solution:
You could also try using$_SERVER['HTTP_REFERER'];
. This might work, not 100% sure though.
Answer
Solution:
You can't do that with server-side code, as there is no server-side variable that refers to what the client sees. The only thing you CAN see (and then again, it depends on the browser the user's using, some don't pass this info) is the HTTP_REFERRER variable. This however, is only set when a page calls another, not when users first access your site.
See this for more details.
A possible solution however, might be to use javascript function to send the browser's top URL to the server using an AJAX query, and to fire it client-side whenever a user loads the pages) you want to get this info for.
Edit: Damn, too slow, already answered!
Answer
Solution:
Pass a hidden input that has the browser value set with your ajax request. Unless someone is being malicious, it should suffice.
Answer
Solution:
If you do an Ajax-request, you could pass the address available through Javascriptswindow.location.href
variable as a POST-variable with the request.
With jQuery it would be something like:
$.ajax({
url: 'your-url.php',
type: "POST",
data: { url: window.location.href },
success: function (data) {
// Do something on success
}
});
With such a request you could access the URL on the server-side with a simple:
<?php
$url = $_POST["url"];
?>
Answer
Solution:
Actual Website Link in php
<?php
echo $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
?>
Answer
Solution:
Server-side languages can't see what happens after they've rendered and outputted the page.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function update() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.