if (!isset($_SERVER['HTTP_REFERER'])) { // Check the url they came from
$url = "Unknown"; // If no URL then show the words Unknown
}
else {
$url = $_SERVER['HTTP_REFERER']; // Shows the URL
$page = new DOMDocument(1.0);
$page->loadHTML(file_get_contents($url));
$title = $pages->getElementsByTagName('title')->item(0)->nodeValue;
}
BTW, you have changed the code. I explained that you MUST check the referer is a URL. Otherwise someone could forge the header and have your script open files on the web server instead of the URL
You should get the message "Call to member function on a non-object". Don't suppress error messages; it makes debugging impossible and wastes your time.
I think opening the referring URL in such a manner is a bad practice, because it results in double the amount of requests for the server hosting the page containing the image (one from the client, and one from the server hosting the dynamic image).
Also, the quotes around $title are superfluous, since $title is a string anyway.
When I remove the quotes around the string I get this "The image “http://localhost:2000/stat%20sig/sig.php” cannot be displayed, because it contains errors." thats why its there.
And I've found a script that can get the page title but I'm having trouble finding the code that does it, the link:-
You should get the message "Call to member function on a non-object". Don't suppress error messages; it makes debugging impossible and wastes your time.
I think opening the referring URL in such a manner is a bad practice, because it results in double the amount of requests for the server hosting the page containing the image (one from the client, and one from the server hosting the dynamic image).
Also, the quotes around $title are superfluous, since $title is a string anyway.
Defiantly, you should at the very least be caching the results.
Why would you want to remove the quotes? You should not have quotes if you are using a single variable. I.e: "$text" is identical to $text.
If you want someone to do it for you then hire someone. You've been given some example code and some advice on how to do it. So how about you tell us what error you are getting and we go from there?
Tip: remove the Content-Type header from the top of the script while debugging, so you can see the error messages.