Skip to content Skip to sidebar Skip to footer

Undefined Index Error Message Php

I'm trying to insert some items from a form into my table which is called products. The form looks like this: As you can see I have mentioned out a link which is Add more supplier

Solution 1:

You have supplier_name_("+next+") in the html, but $_POST['supplier_name_'.$p.''] in php. It differs the (). var_dump ($_POST); in php and check if your html input names match the POST keynames on the error living lines.

Update:

It seems you're using variable variables. Instead of

$supplier_name_ . $p = isset($_POST['supplier_name_'.$p.'']);

try

${'supplier_name_' . $p} = isset($_POST['supplier_name_'.$p.'']);

or

${"supplier_name_$p"} = isset($_POST['supplier_name_'.$p.'']);

See http://php.net/manual/en/language.variables.variable.php

Apply to 'supplier_name_' and others if it works.

Solution 2:

As per your updated question , I believe that loop is ruuning till $p = 3 But you have used static number 5 for condition.

Because value of $p is empty or you can say those does not exists for iteration no. 4 and 5 that is why you are getting issue.

you should get the exact length and use that rather than use $p<=5 directly, just modify this condition in loop , replace 5 with dynamic number.

There 5 should be replaced with length variable.

Post a Comment for "Undefined Index Error Message Php"