0

I have a problem.

Everytime I try to update some records, I get the undefined index error.

Could you guys take a look and see if anything is wrong?

// artikel.php
    <?php
        while($row = mysqli_fetch_array($records)) {

            echo "<tr><form action='updateartikel.php' method='post'>";
            echo "<td><input type='text' name='productcode' value=".$row['Productcode'] . "></td>";
            echo "<td><input type='text' name='product' value=".$row['Product']."></td>";
            echo "<td><input type='text' name='type' value=".$row['Type']."></td>";
            echo "<td><input type='text' name='fabriekcode' value=".$row['Fabriekcode']."></td>";
            echo "<td><input type='text' name='inkoopprijs' value=".$row['Inkoopprijs']."></td>";
            echo "<td><input type='text' name='verkoopprijs' value=".$row['Verkoopprijs']."></td>";
            echo "<input type=hidden name=productcode value='".$row['Productcode']."'>";
            echo "<td><input type='submit' name='wijzigen' value='wijzigen'>";
            echo "</form></tr>";


        }
        ?>

// updateartikel.php
    $productcode = $_POST['productcode'];
    $product = $_POST['product'];
    $type = $_POST['type'];
    $fabriekcode = $_POST['fabriekcode'];
    $inkoopprijs = $_POST['inkoopprijs'];
    $verkoopprijs = $_POST['verkoopprijs'];

    $sql = "UPDATE artikel SET ('Product', 'Type', 'Fabriekcode', 'Inkoopprijs', 'Verkoopprijs', 'Productcode') 
    VALUES ('$product', '$type', '$fabriekcode', '$inkoopprijs', '$verkoopprijs', '$productcode')";

Thanks!

MrPerry
  • 1
  • 1
  • 2
    **WARNING**: When using `mysqli` you should be using [parameterized queries](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and [`bind_param`](http://php.net/manual/en/mysqli-stmt.bind-param.php) to add user data to your query. **DO NOT** use string interpolation or concatenation to accomplish this because you have created a severe [SQL injection bug](http://bobby-tables.com/). **NEVER** put `$_POST` or `$_GET` data directly into a query, it can be very harmful if someone seeks to exploit your mistake. – tadman Jan 11 '17 at 22:02
  • More details on the error? The undefined index should tell you exactly the line where the error is happening – Jose Garrido Jan 11 '17 at 22:02
  • You'e also submitting two `productcode` inputs – bos570 Jan 11 '17 at 22:05

0 Answers0