C
C
cherkashinmichael2019-04-09 01:35:20
PHP
cherkashinmichael, 2019-04-09 01:35:20

Authorization on the site: how to insert a message that the user is already registered?

Login, registration works fine, but now when you click on register, a 403 page opens. How can I make it so that an error box pops up, indicating that the user has already been registered? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Infinite Jackal, 2019-05-19
@infjackal

I have such a thing. Maybe it will help.
Just do not write off exactly the same and correct what. I may have crutches that cannot be earned from you. *^*

$sql = $mysqli->query("SELECT nicknames from table WHERE status = registered AND nicknames = {$nknm}")->num_rows; /* мы просто делаем запрос, что всё записывает в массивы 0, 1, 2... */
       if ($mysqli->error) {
             echo 'Произошла ошибка. Повторите запрос чуть позже.';
             /* вывод ошибки. можно исключить, если уверенность в том, что ничего не сломается, есть */
      } else {
             if ($sql){
                          header ('Location: http://domen/registration_error.php ');
                          /* если запись есть, то мы об этом сообщаем. тут подставляй код, что тебе нужен или написал, ну или отсылай на страницу, как сделал я */
             } else {
                          /* игнор будет работать, но только нужно будет сделать следующее:
                          $mysqli->query("alter table table add primary key (passwords);
                          alter table table add primary key (nicknames);
                          alter table table add primary key (status);");
                          или каждое по отдельности. */
                          $mysqli->query("INSERT IGNORE INTO table SET nicknames = {$nknm} AND status = registered AND passwords = {$pswd}");
                          if ($mysqli->error) {
                                       header ('Location: http://domen/registration_error.php ');
                          } else {
                          /* тут код регистрации. он простой, просто всё записываешь в таблицу. */
                                       print "Регистрация прошла успешно! Направляю на страницу входа..";
                                       header('Refresh: 5; url=http://domen/login.php');
             /* если же записи нет, то мы успешно регистрируем пользователя своим кодом, или примерно так, как я */
            }
         }
      }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question