Undefined index error PHP
Try:
<?php
if (isset($_POST['name'])) {
$name = $_POST['name'];
}
if (isset($_POST['price'])) {
$price = $_POST['price'];
}
if (isset($_POST['description'])) {
$description = $_POST['description'];
}
?>
Apparently the index 'productid' is missing from your html form.
Inspect your html inputs first. eg <input type="text" name="productid" value="">
But this will handle the current error PHP is raising.
$rowID = isset($_POST['rowID']) ? $_POST['rowID'] : '';
$productid = isset($_POST['productid']) ? $_POST['productid'] : '';
$name = isset($_POST['name']) ? $_POST['name'] : '';
$price = isset($_POST['price']) ? $_POST['price'] : '';
$description = isset($_POST['description']) ? $_POST['description'] : '';
This is happening because your PHP code is getting executed before the form gets posted.
To avoid this wrap your PHP code in following if statement and it will handle the rest no need to set if statements for each variables
if(isset($_POST) && array_key_exists('name_of_your_submit_input',$_POST))
{
//process PHP Code
}
else
{
//do nothing
}
TRY
<?php
$rowID=$productid=$name=$price=$description="";
if (isset($_POST['submit'])) {
$rowID = $_POST['rowID'];
$productid = $_POST['productid']; //this is line 32 and so on...
$name = $_POST['name'];
$price = $_POST['price'];
$description = $_POST['description'];
}