A
A
Andrey Kotosin2018-04-28 21:35:53
PHP
Andrey Kotosin, 2018-04-28 21:35:53

How to check for a unique address?

When registering on the site, the user is automatically assigned a unique page address in the format site.ou/id***
Where *** is the line number from the database.
Those. when registering in the database, a new record of the format is created (first name, last name, phone number and, accordingly, an id is automatically created), the id number is taken from there.
The question is how to check the uniqueness of the address?
For example, a person wants to change id123 to durov
1 using the form.
2. How can I prevent a user from choosing an address in the id124 format (because the next registered user will receive this id and it is unacceptable that there would be a conflict of addresses - each must be unique)?
3. How to implement a function similar to that of vk, for example?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
diadiafiodor, 2018-04-29
@diadiafiodor


2. How can I prevent a user from choosing an address in the id124 format (because the next registered user will receive this id and it is unacceptable that there would be a conflict of addresses - each must be unique)?

this is done very simply:
in the query to the database we write
$open ="SELECT * FROM `xxx`.`yyyy` WHERE `user` LIKE ";
The SQL API is such that it has built-in functions, for example, the database will search for matches in itself and return a zero or one, and you just have to process this answer, if there is no match, then fulfill the desire of a respected user and change the name, if there is then no

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question