<form action="t.php" method="post">
<input type="text" name="link" value="">
<input type="submit" name="sub" value="button">
</form>
<?PHP
if (isset($_POST['sub']) ) {
$text = file_get_contents( $_POST['link'] );
preg_match( '/<h2>(.*?)<\/h2>/is' , $text , $title );
echo $title[1];
}
?>