The registered items have several flavors, chocolate, strawberry, vanilla, etc., and each one is inserted by select multiple
in the register, it is saved as "chocolate" but the other selected flavors are not inserted.
PHP Code
if ( ! isset( $_POST ) || empty( $_POST ) ) {
echo '.';
echo '<script>';
echo "Materialize.toast('Impossível continuar!', 4000, 'rounded black');";
echo '$(".success_v2").removeClass("more");
$(".success_v2").removeClass("auth");
$(".loader").hide();
</script>';
exit;
}
foreach ( $_POST as $chave => $valor ) {
$$chave = $valor;
if ( empty( $valor ) ) {
echo '.';
echo '<script>';
echo "Materialize.toast('Existe campo em branco', 4000, 'rounded red');";
echo '$(".success_v2").removeClass("more");
$(".success_v2").removeClass("auth");
$(".loader").hide();
</script>';
}
}
if (
! isset( $nome )
|| ! isset( $marca )
|| ! isset( $categoria )
|| ! isset( $peso )
|| ! isset( $sabor )
|| ! isset( $prod_destaque )
|| ! isset( $preco )
|| ! isset( $codigo )
|| ! isset( $prod_desconto )
|| ! isset( $dob )
) {
echo '.';
echo '<script>';
echo "Materialize.toast('Ainda há campos vázios.', 4000, 'rounded red');";
echo '$(".success_v2").removeClass("more");
$(".success_v2").removeClass("auth");
$(".loader").hide();
</script>';
exit;
}
$prepara = $conexao_pdo->prepare("INSERT INTO 'produtos' ('nome','nome_iso','cod','marca','categoria','status','preco','desconto','data','chns','autor','descricao','peso','sabores','cover','prod_destaque','prod_desconto','link') VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$verifica = $prepara->execute(
array(
$nome,
$nome_cl,
$codigo,
$marca,
$categoria,
$dob,
$preco,
$desconto,
$data,
$chns,
$autor,
$descricao,
$peso,
$sabor,
$novo_nome_imagem,
$prod_destaque,
$prod_desconto,
$link_final
)
);
HTML
<select class="seleciona" name="sabor" multiple="">
<option disabled selected>Selecione o Sabor</option>
<option value="chocolate">chocolate</option>
<option value="morango">morango</option>
<option value="baunilha">baunilha</option>
</select>