Ok so I guess there are many threads about undefined indexes.
I am trying to create a form in which a user can upload both textual information and an image. In my site its adding a watch included information and a picture into a database.
I have two questions. First one why am i getting undefined indexes in this code.
I am connecting to the database using an include include("connect.php");
<form enctype="multipart/form-data" action="" method="POST">
<p>Watch Name: <input type="text" name="item_name"></p>
<p>Watch Model: <input type="text" name="item_model"></p>
<p>Item Description: <textarea id="wysiwyg" rows="11" cols="50" name="item_desc"></textarea></p>
<p>Watch Cost (£): <input type="text" name="item_cost"></p>
<p>Watch Quantity: <input type="text" name="item_qty"></p>
<p>Photo: <input type="file" name="image"></p>
<p><input name="submit" type="submit" class="box" id="upload" value=" Upload ">
<input type="reset" name="reset" value="reset" /></p>
</form>
<?php
$target = 'images/';
$target = $target . basename($_FILES['image']['name']);
$item_name=$_POST['item_name'];
$item_model=$_POST['item_model'];
$item_desc=$_POST['item_desc'];
$item_cost=$_POST['item_cost'];
$item_qty=$_POST['item_qty'];
$image=($_FILES['image']['name']);
mysql_query("INSERT INTO 'stock' VALUES ('$item_name', '$item_model', '$item_desc', '$item_cost', '$item_qty', '$image')");
if(move_uploaded_file($_FILES['image']['tmp_name'], $target))
{
echo "The file ". basename($_FILES['image']['name']). "has been uploaded, and you watch has been added to the catalogue";
}
else {
echo "Sorry, you watch has not been uploaded.";
}
?>
Second question is: Is there any way to make sure you dont get any undefined indexes.
I am fairly new to PHP. Thanks Reece