Registration - comparison of existing or non-existent values

0

I'm doing a registration system in PHP (working normal), my problem is the following in the table has a registration with the name "Test", and wanted to when register another user with the name "Test" or " test ", it was not possible to register, because there is already an equal value in the table.

Does anyone have a solution?

    
asked by anonymous 16.08.2017 / 21:04

2 answers

1

Use the strcasecmp method to compare. See:

$var1 = "Teste";
$var2 = "teste";
if (strcasecmp($var1, $var2) == 0) {
    echo '$var1 é igual a $var2 numa comparação sem diferenciar maiúsculas e minúsculas';
}
    
16.08.2017 / 21:08
1

I do not know what database you are using, but at the time of database creation, in the 'name' field you can set it to unique , which will not be able to register another with the same name.

You can change the table already created as the example:

ALTER TABLE tabela
ADD UNIQUE (coluna);

In this way, the DBMS itself does not allow duplicate value insert.

    
16.08.2017 / 21:32