Skip to content
Advertisement

query gives the same result multiple times

I am doing a CRUD and I’m doing the edit part, I have multiple tables that are related to each other by foreign key, like for example the table ’empleados’ has the foreign key ‘rela_usuarios’ which belongs to the usuarios table and I don’t know how to relate them, so I save the query of usuarios inside a variable and put it on empleados as foreign key. Is that the problem is it another thing?

JavaScript

Also when I executed this all the other record got removed and got replaced by the last update

this is where the tables come from

JavaScript

Advertisement

Answer

When your SELECT is correct, you can do following code, it uses mysqli prepared Statments with parameters, this prevents sql injection.

Like all code this must be tested first with test data to verify that all works as intended.

Wesley Smith also explained in the comment that you should not save passwords as plain text

so please read https://www.php.net/manual/en/faq.passwords.php and https://dev.to/anastasionico/good-practices-php-security-how-to-manage-password-18bm

I used the password hashing already in the code below, see the article how you can verify it in your own code

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement