下面的代码显示由包含产品名称的select标签组成的表单,当我选择特定产品时,它允许编辑其详细信息。我能够更新所有文本数据但无法移动图像文件,它给我一个错误,如未定义索引:图像..请帮我解决这个问题。
<div class="divD">
<p>Product Model Name</p>
<?php
global $target_path1;
$connection = mysql_connect("localhost", "root", "");
$db = mysql_select_db("abc", $connection);
if (isset($_GET['submit']))
{
$id = $_GET['did'];
$m1 = $_GET['model_nm'];
$m2 = $_GET['price'];
$m3 = $_GET['des'];
$target_path1 = "Upload/";
$target_path1 = $target_path1 . basename( $_FILES['image']['name']);
if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path1))
{
echo "The file ". basename( $_FILES['image']['name'])." has been uploaded";
}
$query = mysql_query("update product set model_nm='$m1', price='$m2',des='$m3',img1='$target_path1' where id='$id'");
}
$query = mysql_query("select * from product", $connection);
while ($row = mysql_fetch_array($query)) {?>
<?php echo "<a href='edit_products.php?update={$row['id']}'>{$row['catg_nm']}--{$row['model_nm']}</a>";
echo "<br />";
}?>
</div>
<?php
if (isset($_GET['update'])) {
$update = $_GET['update'];
$query1 = mysql_query("select * from product where id=$update");
while ($row1 = mysql_fetch_array($query1)) {?>
<form class="form" method="get" enctype="multipart/form-data" action="#">
<?php echo "<h2>Update Form</h2>";
echo "<hr/>";
echo "<input class='input' type='hidden' name='did' value='{$row1['id']}' />";
echo "<br />";
echo "<label>" . "Model Name:" . "</label>" . "<br />";
echo "<input class='input' type='text' name='model_nm' value='{$row1['model_nm']}' />";
echo "<br />";
echo "<label>" . "Price:" . "</label>" . "<br />";
echo "<input class='input' type='text' name='price' value='{$row1['price']}' />";
echo "<br />";
echo "<label>" . "Configuration:" . "</label>" . "<br />";
echo "<textarea rows='20' cols='15' name='des'>{$row1['des']}";
echo "</textarea>";
echo "<label>" . "Images:" . "</label>" . "<br />";
echo "<input type='file' name='image' id='image' />";
echo "<br />";
echo "<input class='submit' type='submit' name='submit' value='update' />";
echo "</form>";
}
}
if (isset($_GET['submit'])) {
echo '<div class="form" id="form3"><br><br><br><br><br><br>
<Span>Data Updated Successfuly......!!</span></div>';
}
?>
<?php mysql_close($connection); ?>
&#13;