Hashing PHP password

Started by irfanyounas, Oct 11, 2022, 03:23 AM

Previous topic - Next topic

irfanyounasTopic starter


Hello,
 I'm doing my first petproject and I'm having problems with registration, when I enter data into the field and click register, the entered data is sent to my local database on phpmyadmin, the files create_user, register and connect_user are responsible for creating accounts, create_user creates them.
I would like to make it so that when I enter the password in the "password" field in the registration, it is not just sent to the database (as I have already done), but I also want it to be hashed.
  •  

AvniShergill

Process the password with a hashing function. Write the result to the database. Is it logical?
You need to check not only the result of connecting to the database, but also the result of executing each query.

Why choose the data of all users when registering?
You need to have a field with unique user-oriented identifiers (i.e. a numeric identifier is not suitable for this role), for instance, mail or your username, and create a unique index on it, then the DBMS will not allow creating "duplicate" records.


In MySQL, you can use INSERT IGNORE and look at the number of "affected" records (mysqli::$affected_rows). This amount can be returned in a special function, primarily intended for INSERT, UPDATE, etc. queries, and the error can be "returned" using an exception. That's usually how they do it.
  •