Upload image into database using php

asaneascom

New Member
i am trying to upload image into database using php, i got an error message saying Undefined index: horse_imagehere is the form code:\[code\]<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="http://stackoverflow.com/questions/3869841/m" id="horse_gender_0" /> Male</label><label> <input type="radio" name="horse_gender" value="http://stackoverflow.com/questions/3869841/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="http://stackoverflow.com/questions/3869841/0" selected="selected">please select</option> <option value="http://stackoverflow.com/questions/3869841/13">american</option> <option value="http://stackoverflow.com/questions/3869841/14">asian</option> <option value="http://stackoverflow.com/questions/3869841/11">australian</option> <option value="http://stackoverflow.com/questions/3869841/12">brazilian</option> <option value="http://stackoverflow.com/questions/3869841/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="http://stackoverflow.com/questions/3869841/<?php echo $skills["SKILL_ID"]; ?>"> </td> </tr><?php }?></table><p><input type="Submit" Value="http://stackoverflow.com/questions/3869841/Submit"> <input type="Reset" Value="http://stackoverflow.com/questions/3869841/Clear Form Fields"> </form>\[/code\]here is the code in newhorse.php\[code\]<?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); ?>\[/code\]
 
Back
Top