mysql - php inserts duplicate records -


I am new to php. I have downloaded xampp and 2 column id (primary key, auto-increment), army (INT value)

In my index.php I only have one input text and a submit button:

   

And this is my submit script:

  $ sql = "Enter the update (cena) values ​​('$ _POST [cena]') ) "; Mysqli_query ($ conn, $ sql); Mysqli_query ($ mysqli_query ($ con));} "1 record added" echo; mysqli_close ($ thief);  
< P> When I enter a value in the text input, and the submit button is pressed on the whites: "1 record added" but when I look in my database in phpMyAdmin, I get 2 records.

Example:

I enter 123 in text input

I see phpMyAdmin:

 + ---- + ----- - + | ID | Army | + ---- + ------ + | 1 | 123 | 2 | 123 | + ---- + ------ + 

I Why not use any loops?

thanks

This is because you use the mysqli_query twice:

mysqli_query ($ con, $ sql)

then , when you insert data, and when you if () to check statement, just before removing Mysql_query, for example like that:

  $ sql = "update (sew) include values ​​( '$ _POST [cena]')"; If (! Mysqli_query ($ con, $ sql) () die ( "Error: '. Mysqli_error ($ con));}  

Comments