为什么我的提交默认为 GET?我清楚地将操作标记为“发布”,我不知道为什么


Why is my submit defaulting to GET? I clearly labeled the action as "post" and I'm not sure why

这是用PHP编写的。 我正在尝试使用 mysqli 修改我的数据库,并且能够提取要修改的记录,将它们填充在正确的字段中。 但是,在我进行编辑后,我选择提交,然后将结果连接到 URL 中,即使我清楚地标记为发布。

 <?php
    error_reporting(E_ALL);

    //VALIDATION SECTION
$artisterr = $albumerr = $publishererr = $subgenreerr = $yearerr = $ratingerr = "";
$rating = $artist = $album = $subgenre = $rating = $publisher = $year  =  "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_POST['rating']) {
        $rating = test_input($_POST['rating']);
    }
    if (empty($_POST["artist"])) {
        $artisterr = "Name is required";
    } else {
        $artist = test_input($_POST["artist"]);
    // check if name only contains letters and whitespace
        if (!preg_match("/^[a-zA-Z ]*$/",$artist)) {
            $artisterr = "This field should only contain letters and spaces";
        }
    }
    if (empty($_POST["album"])) {
        $albumerr = "Album Name is required";
    } else {
        $album = test_input($_POST["album"]);
    }
    if (empty($_POST['subgenre'])) {
        $subgenreerr = "The Subgenre is required";
    } else {
        $subgenre = test_input($_POST["subgenre"]);
    }
    if (empty($_POST["Publisher"])) {
        $publishererr = "A publisher is required";
    } else {
        $publisher = test_input($_POST["Publisher"]);
    }
    if (empty($_POST["year"])) {
        $yearerr = "a year is required";
    }  else {
        $year = test_input($_POST["year"]);
    // check if name only contains letters and whitespace
        if (!preg_match("/^[0-9]*$/",$year)) {
            $yearerr = "This field should only contain numbers"; 
        }
    }
}
function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>
<html>
<head>
<style>.error {color: #FF0000} </style> 
</head>
<title>Modify Form </title>
<body>
<header>
<h1> Edit your input </h1>

<?php
// ---------------------CONNECTING TO DATABASE
//Obtain login credentials
require_once 'login.php';
//Create connection to database
$conn = new mysqli($hn, $un, $pw, $db);
//Check if connection succeeded
if ($conn->connect_error) die($conn->connect_error);
//Verify if user already chose record to be Modified from the database table
$id = $_GET['id']; 
//RETRIEVE RECORDS
$currentquery = "SELECT * FROM jazz WHERE id=".$id;
$cr=$conn->query($currentquery);
$rows=$cr->num_rows;
$row=$cr->fetch_array(MYSQLI_NUM);
//UPDATE DATABASE
if (isset($_POST['update']) /*&& isset($_GET['id'])*/){
    if (isset($_POST['artist'])   &&
    isset($_POST['album'])    &&
    isset($_POST['subgenre']) &&
    isset($_POST['rating'])   &&
    isset($_POST['year'])       &&
    isset($_POST['Publisher']))
    {
    $artist = get_post($conn, 'artist');
    $album = get_post($conn, 'album');
    $rating = get_post($conn, 'rating');
    $subgenre = get_post($conn, 'subgenre');
    $publisher = get_post($conn, 'Publisher');
    $year = get_post($conn, 'year');
    $updatequery = "UPDATE jazz SET year = '".$year."', artist = '".$artist."', album = '".$album."', Publisher = '".$publisher."' , subgenre = '".$subgenre."', rating = '".$rating."' where id =".$id;
    $modresult   = $conn->query($updatequery);
    /*if (!$modresult) echo "Modify failed: $updatequery<br>" .
    $conn->error . "<br><br>";*/
    }
#}
/*if (isset($_POST['update'])) {
            if (!empty($_POST['year'])   &&
            !empty($_POST['artist'])   &&
            !empty($_POST['album'])   &&
            !empty($_POST['rating'])   &&
            !empty($_POST['subgenre'])   &&
            !empty($_POST['Publisher'])   &&
            empty($yearerr)   &&
            empty($artisterr)   &&
            empty($albumerr)   &&
            empty($ratingerr)   &&
            empty($subgenreerr)   &&
            empty($publishererr)) {
            $year   = get_post($conn, 'year');
            $artist = get_post($conn, 'artist');
            $album = get_post($conn, 'album');
            $rating = get_post($conn, 'rating');
            $publisher = get_post($conn, 'Publisher');
            $subgenre = get_post($conn, 'subgenre');
            $updatequery = "UPDATE jazz SET year = '".$year."', artist = '".$artist."', album = '".$album."', rating = '".$rating."', subgenre = '".$subgenre."',  Publisher = '".$publisher."' WHERE id=".$id;
            $result   = $conn->query($updatequery);*/
        if($modresult) {
            header("Location:http://ec2-52-201-246-195.compute-1.amazonaws.com/Project2/view.php");
        }
        elseif(!$modresult) {
            header('Location:http://ec2-52-201-246-195.compute-1.amazonaws.com/Project2/add_test.php');
            }
        #}
    }

?>

<form>
    <form method="post" >
        <fieldset>
            Year    <input  type="text" name="year"   id = "year"   value = "<?php echo $row[1];?>"/>  <span class = "error">* <?php echo $yearerr;  ?> </span><br><br>
            Artist  <input  type="text" name="artist" id = "artist" value = "<?php echo $row[2];?>"/>  <span class = "error">* <?php echo $artisterr;?> </span><br><br>
            Album   <input  type="text" name="album"  id = "album"  value = "<?php echo $row[3];?>"/>  <span class = "error">* <?php echo $albumerr; ?> </span><br><br>
            Publisher<span class = "error">* <?php echo $publishererr;?></span><br>
                <input type = "radio" name=  "Publisher" <?php if ($row[4]=="Columbia") echo "checked";?> value="Columbia" id="Columbia" > Columbia <br>
                <input type = "radio" name = "Publisher" <?php if ($row[4]=="Okeh")     echo "checked";?> value="Okeh"     id="Okeh" > Okeh         <br>
                <input type = "radio" name = "Publisher" <?php if ($row[4]=="RCA")      echo "checked";?> value="RCA"      id="RCA" > RCA           <br>
                <input type = "radio" name = "Publisher" <?php if ($row[4]=="Nonesuch") echo "checked";?> value="Nonesuch" id="Nonesuch" > Nonesuch <br>
                <input type = "radio" name = "Publisher" <?php if ($row[4]=="Atlantic") echo "checked";?> value="Atlantic" id="Atlantic" > Atlantic <br><br>
            Subgenre <span class = "error">* <?php echo $subgenreerr;?></span> <br>
            <select name = "subgenre" name = "subgenre">
                <option value= ""> </option>
                <option value="Ragtime"    <?php if($row[5] == "Ragtime")    echo "selected";?>>Ragtime</option>
                <option value="Dixieland"  <?php if($row[5] == "Dixieland")  echo "selected";?>>Dixieland</option>
                <option value="Blues"      <?php if($row[5] == "Blues")      echo "selected";?>>Blues</option>
                <option value="Swing"      <?php if($row[5] == "Swing")      echo "selected";?>>Swing</option>
                <option value="Bebop"      <?php if($row[5] == "Bebop")      echo "selected";?>>Bebop</option>
                <option value="Cool Jazz"  <?php if($row[5] == "Cool Jazz")  echo "selected";?>>Cool Jazz</option>
                <option value="Hard Bop"   <?php if($row[5] == "Hard Bop")   echo "selected";?>>Hard Bop</option>
                <option value="Modal Jazz" <?php if($row[5] == "Modal Jazz") echo "selected";?>>Modal Jazz</option>
                <option value="Funk"       <?php if($row[5] == "Funk")       echo "selected";?>>Funk</option>
                <option value="Symphonic"  <?php if($row[5] == "Symphonic")  echo "selected";?>>Symhonic</option>
                <option value="Orchestral" <?php if($row[5] == "Orchestral") echo "selected";?>>Orchestral</option>
            </select></br><br>
            Rating <span class = "error">* <?php echo $ratingerr;?></span><br>
            <input type = "range" name="rating" min="1" max="10" value = "<?php echo $row[6];?>"><br><br>
            <input type = "submit" name= "update" value = "Update" />
            </fieldset>
    </form>
    <footer>  <a href='Project - Homepage.html'>Home</a> </footer>
<?php

    $modresult->close();
    $conn->close();
    function get_post($conn, $var)
    {
    return $conn->real_escape_string($_POST[$var]);
    }
?>
</body>    
</html>

我看到两个表单标签。 我想知道为什么会这样...