I am trying to insert data from a form to mySQL DB, no connection error, but no data is inserted into my database. Any idea? Here's my HTML form:

[upl-image-preview url=https://board.phpbuilder.com/assets/files/2020-05-01/1588327577-431130-5.png]

PHP Form =
[upl-image-preview url=https://board.phpbuilder.com/assets/files/2020-05-01/1588327638-684767-5.png]

    The submit button name is not always sent with the rest of the form data AFAICR. Try switching isset($_POST['simpan']) to $_SERVER['REQUEST_METHOD'] == 'post'. The other option is to output $_POST before the if statement and make sure it contains what you think it contains.

      Meanwhile, use mysqli_error to find see what error prevented the data from being stored (instead of just saying "Data Not Stored").

      And for code that is intended for use in the real world, do not embed user-supplied data directly into database commands.

      Weedpacket And for code that is intended for use in the real world, do not embed user-supplied data directly into database commands.

      As Weedpacket points out, if you put user-supplied data directly into your SQL commands, you run the risk of SQL injection.

      13 days later
      Write a Reply...