I'm creating an online store, and I need to add the products on the site through DB.
To facilitate, I want to create a graphical part, which is already done, but in my variables gives me the following error:
Notice: Undefined index: product_code in /home/i12184/public_html/admin.php on line 4
Notice: Undefined index: product_name in /home/i12184/public_html/admin.php on line 5
Notice: Undefined index: $ product_desc in /home/i12184/public_html/admin.php on line 6
Notice: Undefined index: $ product_img_name in /home/i12184/public_html/admin.php on line 7
Notice: Undefined index: price in /home/i12184/public_html/admin.php on line 8
My code:
$product_code = $_POST['product_code'];
$product_name = $_POST['product_name'];
$product_desc = $_POST['$product_desc'];
$product_img_name = $_POST['$product_img_name'];
$price =$_POST['price'];
$insert ='insert into products (product_code, product_name, product_desc, product_img_name, price)
Values("'.$product_code.'", "'.$product_name.'", "'.$product_desc.'",
"'.$product_img_name.'", "'.$price.'")';
mysql_query($insert);
Html
<form action="admin.php" method="post" onsubmit="formsubmit(this)">
Codigo do Produto: <input type="text" name="product_code" /><br /><br />
Nome do Produto: <input type="text" name="product_name" /><br /><br />
Descricao do Produto: <input type="tinytext" name="product_desc" /><br /><br />
Nome da Imagem do Produto: <input type="text" name="product_img_name" /><br /><br />
Preco: <input type="decimal" name="price" /><br /><br />
<input type="submit" value="Enviar">
</form>
<script>
function formsubmit(form)
{
form.submit();
}
</script>