How to get previous page title
You can use $_SERVER['HTTP_REFERER'] with PHP to get the URL of the last page you were on. This is not a reliable solution because not all user agents support it. plus users can manually intervene with the previous page and mess things up.

If a client side solution is sufficient for you, you can use javascript's document.referrer.

You could use a querystring as well and append that to the URL and read it from the page you're going to.

website.com/secondPage?refer=lastPageIWasOn

// then grab the value from the second page
$last_page_value = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';

// or use drupal_get_query_parameters()

// Then do something with it


Or you could use cookie/session to do this

if (!isset($_SESSION)) {
    session_start();
}
if (!isset($_SESSION['referrer'])) {
    $_SESSION['lastpage'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
}

// second page
$referer = isset($_SESSION['lastpage']) ? $_SESSION['lastpage'] : '';


This is a very common use case and StackOverflow has several questions on it with PHP. I suggest googling it. Translating it to drupal will depend on what you're doing with it.