How to implement this:

If there is a username in the database (for example, user), and when registering, a new user tries to write the same name (user) as creating a request so that there is a message in this case, like "Sorry, but a user with that name already exists" For example my request:

if (!empty($_POST)) { if (($_POST['url'] != "") and ($_POST['name'] != "")) { $sql="INSERT INTO woo_pages (url,name,description,keywords,title,active) VALUES ('/".(trim($_POST['url']))."/','".(trim($_POST['name']))."','".(trim($_POST['description']))."','".(trim($_POST['keywords']))."','".(trim($_POST['title']))."','".(trim($_POST['active']))."')"; if (mysql_query($sql)); echo "success"; } } 

    2 answers 2

     Select user from table where user = newuser 

    If the answer is returned, then the name is taken

      If you want to check the existence of such a user at the stage of writing to the table, then put uniqueness on the user field, then when you try to insert a record with such user, an error will return that you need to catch and, according to it, say return message username is already there.

      But the correct existence of such a user must also be checked at the level of validation of user-entered data.