Php kullanarak veritabanına resmi yükleyin

0 Cevap php

horse_image: i php kullanarak veritabanına resim yüklemek için çalışıyorum, ben Undefined index söyleyerek bir hata mesajı var

Burada Form kodu:

<form method="post" enctype="multipart/form-data"action="newhorse.php"
OnSubmit="return VerifyDataEntry(this)">  
<p>Please type the horse details below 
<p>Horse Id: <input type="text" name="horse_id">  
<p>Horse name: <input type="text" name="horse_name">
<p>Horse Gender: <span id="spryradio1">
<label>
  <input type="radio" name="horse_gender" value="m" id="horse_gender_0" />
  Male</label>

<label>
  <input type="radio" name="horse_gender" value="f" id="horse_gender_1" />
  Female</label>
<br />
<span class="radioRequiredMsg">Please make a selection.</span></span>

<p>Horse Height: <input type="text" name="horse_height">
<?php
  if (!isset($_FILES["horse_image"]["tmp_name"]))
  {
 ?>

        <p>Select an image to upload:
          <input type="file" size="50" name="horse_image">


<?php
  }
  else
  {
    $upfile = "horse_images/".$_FILES["horse_image"]["name"];

    $imgsize=getimagesize($_FILES["horse_image"]["tmp_name"]);

    if(!move_uploaded_file($_FILES["horse_image"]
      ["tmp_name"],$upfile))
    {
      echo "ERROR: Could Not Move File into Directory";
    }

  }
 ?>
<p><span id="spryselect1">
<label for="horse_breed">Horse Breed: </label>
<select name="horse_breed" id="horse_breed">
  <option value="0" selected="selected">please select</option>
  <option value="13">american</option>
  <option value="14">asian</option>
  <option value="11">australian</option>
  <option value="12">brazilian</option>
  <option value="15">europian</option>
</select>
<?php
  include("connection.php"); 
     $conn = oci_connect($UName,$PWord,$DB);
  $query = "Select * FROM skill ORDER BY SKILL_DESC";
    $stmt = oci_parse($conn,$query);
  oci_execute($stmt);
?>
<p>Select horse skill(s)
<p>
<table border="2" cellpadding="4">
  <tr>
    <th>Skill Id</th>
    <th>Skill Name</th>
    <th>Add?</th>
  </tr>
  <?php 
  while ($skills = oci_fetch_array ($stmt))
  {
?>
    <tr>
      <td><?php echo $skills["SKILL_ID"]; ?></td>
      <td><?php echo $skills["SKILL_DESC"]; ?></td>
      <td align="center">

<input type="checkbox" name="check[]" value="<?php echo $skills["SKILL_ID"]; ?>">

      </td>
    </tr>
<?php
  }
?>

</table>
<p><input type="Submit" Value="Submit">  <input type="Reset" Value="Clear Form Fields">  
</form>

Burada newhorse.php yılında kodudur

<?php 
$horse_id = $_POST["horse_id"]; 
$horse_name = $_POST["horse_name"]; 
$horse_gender = $_POST["horse_gender"];
$horse_height = $_POST["horse_height"];
$horse_image = $_POST["horse_image"];
$horse_breed = $_POST["horse_breed"];
?> 
    <table border="0">  
    <tr>  
    <td>Horse Id: <?php echo $_POST["horse_id"]; ?></td>  
    </tr>  
    <tr>  
    <td>Horse Name: <?php echo $_POST["horse_name"]?> </td> 
    </tr>  
    <tr>  
    <td>Horse Gender: <?php echo $_POST["horse_gender"] ?></td>  
    </tr>  
    <tr>  
    <td>Horse Height: <?php echo $_POST["horse_height"] ?></td>  
    </tr>
    <tr>  
    <td>Horse Image: <?php echo $_POST["horse_image"]
     ?></td>  
    </tr>
    <tr>  
    <td>Horse Breed: <?php echo $_POST["horse_breed"] ?></td>  
    </tr>
    </table> 




    <?php

          include("connection.php");
          $conn = oci_connect($UName,$PWord,$DB);

          $query="INSERT INTO horse (horse_id, horse_name,horse_gender,horse_height,horse_image,horse_breed) VALUES('$_POST[horse_id]','$_POST[horse_name]','$_POST[horse_gender]','$_POST[horse_height]','$_POST[horse_image]','$_POST[horse_breed]')";

          $stmt = oci_parse($conn,$query);
          oci_execute($stmt); 


    ?>

0 Cevap