The <title>
tag of page X's referring page is not going to be stored anywhere in X. You will need to request the referring page to get its <title>
tag.
Here is a link to some PHP code that will do this:
Grab the title of a web page (local or remote)
I'm going to alter the code a bit to fit your use-case:
<?php
$file = @ fopen($_SERVER['HTTP_REFERER'],"r") or die ("Can't open HTTP_REFERER.");
$text = fread($file,16384);
if (preg_match('/<title>(.*?)<\/title>/is',$text,$found)) {
$title = $found[1];
} else {
$title = " -- no title found -- ";
}
?>
Just keep in mind that you can't trust the HTTP_REFERER
variable, since the browser (or plugins, etc.) can change it. (1)