Hello, good afternoon, I'm not able to register category and subcategory.
<?php
require_once 'sessao.php';
require_once 'connection.php';
$stmt = $conexao->query('select * from categoria');
$categorias = $stmt->fetchAll(PDO::FETCH_OBJ);
?>
<html>
<head>
<meta charset="UTF-8" />
<script src="js/jquery-1.10.1.min.js"></script>
<script src="js/busca_categoria.js"></script>
<script src="../ckeditor.js"></script>
</head>
<body>
<form action="produto.php" method="post" enctype="multipart/form-data">
Categoria:<br>
<select name="categoria" id="categoria">
<option value="">Selecione Uma Opcao</option>
<?php foreach ($categorias as $categoria ): ?>
<option value="<?php echo $categoria->id_categoria;?>"><?php echo $categoria->tx_nome;?></option>
<?php endforeach ?>
</select>
<br><br>
Subcategoria:<br>
<select name="subcategoria" id="subcategoria">
</select>
<input type="file" name="file_img[]" multiple />
<input type="submit" name="btn_upload" value="Upload" />
</form>
<?php
if(isset($_POST['btn_upload']))
{
$con = mysqli_connect("localhost","otimi314_imagens","WkJJu336@otimi","otimi314_naoapagar");
for($i=0; $i<count($_FILES["file_img"]["name"]); $i++)
{
$filetmp = $_FILES["file_img"]["tmp_name"][$i];
$filename = $_FILES["file_img"]["name"][$i];
$filetype = $_FILES["file_img"]["type"][$i];
$filepath = "imagens/fotos/" .$filename;
move_uploaded_file($filetmp,$filepath);
$sql = "INSERT INTO produto (tx_imagem,img_path,img_type,id_subcategoria,id_categoria) VALUES ('$filename', '$filepath', '$filetype', 'categoria', 'subcategoria')";
mysqli_query($con, $sql);
}
}
?>
</body>
</html>