You could store the information user in comming from a known referer
in the first place when you ckeck it the first time:
$allowed_referer = array("https://localhost/**blah.php**"); //add the allowed sites in this array
$referal = $_SERVER['HTTP_REFERER'];
if (in_array($referal, $allowed_referer)){
//Store a flag in the session
$_SESSION['come_from_known_referer'] = true;
//Do-stuff
}
And then modify your code:
<?php if (!isset($_SESSION['come_from_known_referer'])){ ?>
<button type="submit" name="submit" value="submit-new"> Submit </button>
<?php } else { ?>
<button type="submit" name="submit" value="save-new"> Save </button>
<?php } ?>
As a sidenote, remember that a user can hide or modify the headers send to your server so do not rely on this for critical functionalities.