将记录更新到同一页面

I have a simple database through which I would like update a number of records. There is one record per page, and the user can click to move to the first, next, previous, and last records. The pagination works, as does the update. What does not work (and which is annoying me) is the fact that when the button is clicked it does not return to the same record, nor does it display the most recently entered values. Navigating away and then back again shows that the update has been successful. I am sure that part of the problem lay with the following:

<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >

I would really appreciate any help with this. It might be very simple, but has eluded me. I paste the full code below. Thank you.

<?php
$id = "";
$fname = "";
$lname = "";
$email = "";
$selected="";
if ( isset( $_POST[ 'id' ] ) ) {
    $id = $_POST[ 'id' ];
}
if ( isset( $_POST[ 'fname' ] ) ) {
    $fname = $_POST[ 'fname' ];
}
if ( isset( $_POST[ 'lname' ] ) ) {
    $lname = $_POST[ 'lname' ];
}
if ( isset( $_POST[ 'email' ] ) ) {
    $email = $_POST[ 'email' ];
}
if ( isset( $_POST[ 'submit' ] ) ) {
    $selected = implode(', ', (array)$_POST['warning']);
}
?>
<?php
$connect = mysqli_connect( "localhost", "", "", "ps10" );
$record_per_page = 1;
$page = '';

if ( isset( $_GET[ 'page' ] ) ) {
    $page = $_GET[ 'page' ];
} else {
    $page = 1;
}
$start_from = ( $page - 1 ) * $record_per_page;
$query = "SELECT * FROM studentdata LIMIT $start_from, $record_per_page";
$result = mysqli_query( $connect, $query );
?>
<!DOCTYPE html>
<html>
<head>
    <title>Pagination</title>
</head>

<body>
    <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >

        <table width='50%' border='1'>
            <?php
            while ( $row = mysqli_fetch_array( $result ) ) {
                ?>
            <tr>
                <td>ID</td>
                <td><input name="id" id="id" value="<?php echo $row['id']; ?>" size="40">
                </td>
            </tr>
            <tr>
                <td>First Name</td>
                <td><input name="fname" type="text" id="fname" value="<?php echo $row['fname']; ?>" size="40">
                </td>
            </tr>
            <tr>
                <td>Last Name</td>
                <td><input name="lname" type="text" id="lname" value="<?php echo $row['lname']; ?>" size="40">
                </td>
            </tr>
            <tr>
                <td>Email</td>
                <td><input name="email" type="text" id="email" value="<?php echo $row['email']; ?>" size="40">
                </td>
            </tr>
            <tr>
                <td>Warnings</td>
                <td><input name="selected" type="text" id="selected" value="<?php echo $row['selected']; ?>" size="120">
                </td>
            </tr>
            <?php
            }
            ?>
        </table>
            <input type="checkbox" name="warning[]" value="more than 10% is quoted material">More than 10% is quoted material
            <br><br>
            <input type="checkbox" name="warning[]" value="question not answered">Question not answered
            <br><br>
            <input type="checkbox" name="warning[]" value="significant plagiarism">Significant plagiarism
            <br><br>
            <input type="checkbox" name="warning[]" value="more than 10% underlength">More than 10% underlength
            <br><br>
            <input type="checkbox" name="warning[]" value="possibly not own work">Possibly not own work
            <br><br>
            <br>
            <input name="submit" type="submit" class="button1" value="Update Record">
                    </td>
        </form>
        <?php
        $sql = "UPDATE studentdata SET fname='$fname', lname='$lname', email='$email', selected='$selected' WHERE id='$id'";
        $result = mysqli_query( $connect, $sql );
        ?>
        <p>
            <?php
            echo "<table width = '50%' border = '0'>";
            ?>
            <?php
            $page_query = "SELECT * FROM studentdata ORDER BY id ASC";
            $page_result = mysqli_query( $connect, $page_query );
            $total_records = mysqli_num_rows( $page_result );
            $total_pages = ceil( $total_records / $record_per_page );
            $start_loop = $page;
            $difference = $total_pages - $page;
            if ( $difference <= 2 ) {
                $start_loop = $total_pages - 2;
            }
            $end_loop = $start_loop + 1;
            if ( $page > 1 ) {
                echo "<tr><td align ='center' width ='25%' ><a href='student_record_pagination_update.php?page=1'>First</a></td>";
                echo "<td align ='center' width ='25%'><a href='student_record_pagination_update.php?page=" . ( $page - 1 ) . "'>Previous</a></td>";
            }
            for ( $i = $start_loop; $i <= $end_loop; $i++ ) {
                echo "<a href='student_record_pagination_update.php?page=" . $i . "'></a>";
            }
            if ( $page <= $end_loop ) {
                echo "<td align ='center' width ='25%' ><a href='student_record_pagination_update.php?page=" . ( $page + 1 ) . "'>Next</a></td>";
                echo "<td align ='center' width ='25%' ><a href='student_record_pagination_update.php?page=" . $total_pages . "'>Last</a></td>";
            }
            ?>
            <?php
            echo "</table>";
            ?>
</body>
</html>