开发者

PHP registration script: verifying and telling the user what went wrong

开发者 https://www.devze.com 2023-01-01 15:47 出处:网络
I\'m building a registration script and I want to insert the user\'s input (username, mail) ONLY if it\'s not already in the database. What I usually do in such cases is a request to see if something\

I'm building a registration script and I want to insert the user's input (username, mail) ONLY if it's not already in the database. What I usually do in such cases is a request to see if something's already there, something like: "SELECT * FROM things WHERE thing_name = '$treated_user_input'".

I have two fields that need to be unique this time though. Is there a way to do only one SELECT request and still be able to tell the user exactly what field went wrong?开发者_如何学Python Or do I have to do one request per unique field?

Thanks for your answers.


Look at SQL distinct for 2 fields in a database for selecting two distinct fields. At that point, if you have at least one result, you can use PHP to determine which is the offending field.

0

精彩评论

暂无评论...
验证码 换一张
取 消