0
I am developing a system for my school’s library and would like to know how to make a script in PHP, with Mysql database, which, at the time of registration, check if there is a record with that CPF.
0
I am developing a system for my school’s library and would like to know how to make a script in PHP, with Mysql database, which, at the time of registration, check if there is a record with that CPF.
Browser other questions tagged php mysql
You are not signed in. Login or sign up in order to post.
Easier and safer to place the field of
CPF
asUNIQUE
, this way the database will not allow repeated values and will return an error while trying.– Thiago Magalhães
Right, but how can I customize this error, like; "This number has already been registered."
– Gabriel Camurça
These errors have a
código
and amensagem
default. You can force the error and catch thecódigo
returned, having it, just do a validation for when the error has thiscódigo
, return the desired message.– Thiago Magalhães
Understood, but you can give me an example (with code)?
– Gabriel Camurça
Later I put, I’m not in time to make the code. You’re using
MySQLi
orPDO
?– Thiago Magalhães