i am getting this error when i process this form
Notice: Undefined index: image in C:\xampp2\htdocs\trail\auction_upload.php on line 10
Notice: Undefined index: image in C:\xampp2\htdocs\trail\auction_upload.php on line 13
<?php
session_start();
$_SESSION['message']="";
$mysqli = new mysqli('localhost', 'root', '','auction');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$item_name = $mysqli->real_escape_string($_POST['item_name']);
$item_description = $mysqli->real_escape_string($_POST['item_description']);
$item_image = $mysqli->real_escape_string('images/item_img/'.$_FILES['image']['name']);
//make sure file is of image type
if (preg_match("!image!", $_FILES['image']['type'])) {
if (copy($_FILES['image']['tmp_name'], $item_image)) {
$_SESSION['item_name'] = $item_name;
$_SESSION['item_description'] = $item_description;
$_SESSION['image'] = $item_image;
$sql = "INSERT INTO items (item_name, item_image, item_description)
VALUES('$item_name', '$image','$item_description')";
if ($mysqli->query($sql) == true) {
$_SESSION['message'] = "Item Upload Successful!";
} else {
$_SESSION['message'] = "file upload failed";
}
}
else{
$_SESSION['message'] = "file copying failed";
}
}
else {
$_SESSION['message'] = "please upload gif, jpg, png";
}
}
?> <html> <head> <title>Upload item</title> <link rel="StyleSheet" href="Bootstrap/css/bootstrap.main.css"> <link rel="StyleSheet" href="Bootstrap/css/bootstrap.min.css"> <link rel="StyleSheet" href="style.css"> </head> <body> <div> <form class="form-horizontal" role="form" action="auction_upload.php" method="POST"> <div class=" form-group"> <label class="control-label col-sm-2">Item Name:</label> <div class="col-sm-8"> <INPUT type="text" class="form-control" name="item_name" required/> </div> </div> <div class="form-group"> <label class="control-label col-sm-2">Item Image:</label> <div class="col-sm-8"> <INPUT type="file" class="form-control" name="image" accept="image/*" required/> </div> </div> <div class="form-group"> <label class="control-label col-sm-2">Item Description:</label> <div class="col-sm-8"> <textarea class="form-control" name="item_description" required>