How to prevent duplicate Usernames in php/mysql

后端 未结 4 1549
滥情空心
滥情空心 2021-01-17 04:47

(This is my first try with php)

I have a very basic register page. http://graves-incorporated.com/test_sites/member_test/register/register.php

* I j

4条回答
  •  渐次进展
    2021-01-17 05:36

    You can use ajax query before submit to check/prevent is already exists Also in back-end after you do INSERT INTO... you can do SELECT FOUND_ROWS() to check if it's actually equals 1, it means one row inserted. Then redirect user to error page with information what is not correct. For better user experience, I recommend first option, with JQuery it will not take a lot of time to implement.

提交回复
热议问题