未定义的数组键 "image"

Undefined Array Key "image"

当我在我的表单中上传图片时,它给我未定义的数组键“图片”,我给了它 EncType 和正确的名称,但我不知道问题出在哪里

MySQL插入代码

if ($_SERVER['REQUEST_METHOD'] == "POST") {
  if (isset($_POST['send'])) {
    $First_Name = $_POST['First_Name'];
    $Last_Name = $_POST['Last_Name'];
    $Email = $_POST['Email'];
    $Phone = $_POST['Phone'];
    $Password = sha1($_POST['Password']);
    $country = $_POST['country'];
     $image = $_POST['image'];

    if (isset($_POST['image'])) {
      $imageName = $_FILES['image']['name'];
      $imageType = $_FILES['image']['type'];
      $imageTmp = $_FILES['image']['tmp_name'];
      move_uploaded_file($imageTmp, "images/", $image);
    }
    $sql = "INSERT INTO users(first_name,last_name,email,phone,password,country,image) VALUES ('$First_Name','$Last_Name','$Email','$Phone','$Password','$country','$image')";
  }
}

HTML代码

    <form method="POST" action="index.php" enctype="multipart/form-data">
      
           <div class="form-group">
        <label for="exampleInputPassword2">image</label>
        <input type="file" class="form-control" id="exampleInputPassword2" name="image">
      </div>


    </form>

请检查我下面的代码。对你有帮助。

if ($_SERVER['REQUEST_METHOD'] == "POST") {
  if (isset($_POST['send'])) {
    $First_Name = $_POST['First_Name'];
    $Last_Name = $_POST['Last_Name'];
    $Email = $_POST['Email'];
    $Phone = $_POST['Phone'];
    $Password = sha1($_POST['Password']);
    $country = $_POST['country'];
    $image = $_FILES['image']['name'];
    $folder = "images/".$image;


    if (isset($image)) {
      $imageName = $_FILES['image']['name'];
      $imageType = $_FILES['image']['type'];
      $imageTmp = $_FILES['image']['tmp_name'];
      move_uploaded_file($imageTmp,$folder);

    }


$sql = "INSERT INTO users(first_name,last_name,email,phone,password,country,image) VALUES ('$First_Name','$Last_Name','$Email','$Phone','$Password','$country','$image')";`
      }
    }