PDO更新不返回变量

I'm trying to use PDO to update a row in my postgres database.

The form is not sending the variables to the handler file.

I'm not sure where the problem lies, I've been battling with this for a few days.

Form

//$maxContent is set and available
//$context_number is set and available
    echo"<form method='post' action='updateSpatialPhoto_handler.php'>";

    $query3 = $conn->prepare("SELECT * FROM excavation.contexts_spatial_photographs 
        WHERE contexts_spatial.area_easting = {$_SESSION['area_easting']} 
        AND contexts_spatial.area_northing = {$_SESSION['area_northing']} 
        AND contexts_spatial.context_number = {$_SESSION['context_number']}"); 

//contexts_spatial_photographs
    $query3->execute();

while($r = $query3->fetch(PDO::FETCH_OBJ))
    {
    // for each needed
        echo"<input type='hidden' name='photograph_date' value='".$r->photograph_date."'>";
        echo"<input type='hidden' name='photograph_number' value='".$r->photograph_number."'>";
        echo"<input type='hidden' name='primary_shot' value='".$r->primary_shot."'>";

        echo"<input type='hidden' name='maxContext' value='", $maxContext,"'>";
    };

    echo"<input type='submit' value='Update Spatial Photo'>";
echo "</form>";

handler

    <?php
    session_start();

    //
    include 'connect/connect.php';
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    if (!isset($_SESSION['photograph_date'])) {$_SESSION['photograph_date'] = $_POST['photograph_date'];}
    if (!isset($_SESSION['photograph_number'])) {$_SESSION['photograph_number'] = $_POST['photograph_number'];}
    if (!isset($_SESSION['primary_shot'])) {$_SESSION['primary_shot'] = $_POST['primary_shot'];}
    if (!isset($_SESSION['maxContext'])) {$_SESSION['maxContext'] = $_POST['maxContext'];}

    if (isset($_SESSION['photograph_date'])) {$_SESSION['photograph_date'] = $_POST['photograph_date'];}
    if (isset($_SESSION['photograph_number'])) {$_SESSION['photograph_number'] = $_POST['photograph_number'];}
    if (isset($_SESSION['primary_shot'])) {$_SESSION['primary_shot'] = $_POST['primary_shot'];}
    if (isset($_SESSION['maxContext'])) {$_SESSION['maxContext'] = $_POST['maxContext'];}

    //echo "Photograph Date: "; echo $_SESSION['photograph_date']; echo "<br />";
    //echo "Photograph Number: "; echo $_SESSION['photograph_number']; echo "<br />";
    //echo "Primary Shot: "; echo $_SESSION['primary_shot']; echo "<br />";

try {
    $sql3 = "UPDATE excavation.contexts_spatial_photographs SET 
        context_number = :context_number 
        WHERE contexts_spatial_photographs.area_easting = $area_easting
        AND contexts_spatial_photographs.area_northing = $area_northing
        AND contexts_spatial_photographs.context_number = $context_number";

    $stmt2 = $conn->prepare($sql3);

    // prepare sql and bind parameters 
    $stmt2->bindParam(':context_number', $maxContext, PDO::PARAM_INT);
    $stmt2->execute(); 

    echo "Record updated successfully in contexts spatial photographs<br />";

    }
catch(PDOException $e)
    {
     echo "Error: " . $e->getMessage();
    }

?>

At the top of the handler, your using lines like...

if (isset($_SESSION['maxContext'])) {$_SESSION['maxContext'] = $_POST['maxContext'];}

These are setting the values in the session variables, which is fine. But in your SQL -

 AND contexts_spatial_photographs.context_number = $maxContext";

$maxContext doesn't seem to be set anywhere. This may be the same as the session variables, so you need

$maxContext = $_SESSION['maxContext'];

or

 AND contexts_spatial_photographs.context_number = $_SESSION['maxContext']";

Although it would be even better if you use bindParam with them, the same way you use it with :context_number.