How to prevent form resubmission when page is refreshed

I searched for solution to prevent resubmission in a huge project afterwards. The code highly works with $_GET and $_POST and I can’t change the form elements behaviour without the risk of unforeseen bugs. So, here is my code:

<?php
// Store this test code into index.php
// It only works to avoid the resubmit of $_POST, not $_GET. But this is the behaviour I need. 
// This resubmit solution doesn't work with file uploads!

// Very top of your code:

// Start session:
session_start();

// If Post Form Data send and no File Upload
if ( empty( $_FILES ) && ! empty( $_POST ) ) {
	// Store Post Form Data in Session Variable
    $_SESSION["POST"] = $_POST;
	// Reload Page if there were no outputs
	if ( ! headers_sent() ) {
		// Build URL to reload with GET Parameters
        // Change https to http if your site has no ssl
	    $location = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		// Reload Page
	    header( "location: " . $location, true, 303 );
		// Stop any further progress
	    die();
	}
}

// Rebuilt POST Form Data from Session Variable
if ( isset( $_SESSION["POST"] ) ) {
    $_POST = $_SESSION["POST"];
    // Tell PHP there is a POST
    $_SERVER['REQUEST_METHOD'] = 'POST';
}

// Your code:
?><html>
    <head>
        <title>GET/POST Resubmit</title>
    </head>
    <body>

    <h1>Forms:</h1>
    <h2>GET Form:</h2>
    <form action="index.php" method="get">
        <input type="text" id="text_get" value="test text get" name="text_get"/>
        <input type="submit" value="submit">
    </form>
    <h2>POST Form:</h2>
    <form action="index.php" method="post">
        <input type="text" id="text_post" value="test text post" name="text_post"/>
        <input type="submit" value="submit">
    </form>
    <h2>POST Form with GET action:</h2>
    <form action="index.php?text_get2=getwithpost" method="post">
        <input type="text" id="text_post2" value="test text get post" name="text_post2"/>
        <input type="submit" value="submit">
    </form>
    <h2>File Upload Form:</h2>
    <form action="index.php" method="post" enctype="multipart/form-data">
        <input type="file" id="file" name="file">
        <input type="submit" value="submit">
    </form>

    <h1>Results:</h1>
    <h2>GET Form Result:</h2>
    <p>text_get: <?php echo $_GET["text_get"]; ?></p>
    <h2>POST Form Result:</h2>
    <p>text_post: <?php echo $_POST["text_post"]; ?></p>
    <h2>POST Form with GET Result:</h2>
    <p>text_get2: <?php echo $_GET["text_get2"]; ?></p>
    <p>text_post2: <?php echo $_POST["text_post2"]; ?></p>
    <h2>File Upload:</h2>
    <p>file:
    <pre><?php if ( ! empty( $_FILES ) ) {
			echo print_r( $_FILES, true );
		} ?></pre>
    </p>
    <p></p>
</body>
</html><?php
// Very Bottom of your code:
// Kill Post Form Data Session Variable, so User can reload the Page without sending post data twice
unset( $_SESSION["POST"] );