H
H
HeartOfProgrammer2015-10-08 16:49:59
PHP
HeartOfProgrammer, 2015-10-08 16:49:59

What is the problem with creating a registration form?

I made a registration form in PHP + MySQL, read the article on Habré . Everything is written as it should, there are no errors. The only thing that does not work is the submit button (Register), it stupidly does not react to anything, nothing happens. The user is not entered into the database.
register.php:

<from method="post">
    Логин <input name="login" type="text"><br>
    Пароль <input name="password" type="password"><br>
    <input name="submit" type="submit" value="Зарегистрироваться">
  </from>

  <?
  $link = mysqli_connect('localhost','Nightik','qwerty','register');

  if(isset($_POST['submit'])) {
    $err = array();

    if(!preg_match("/^[a-zA-Z0-9]+$/",$_POST['login'])) {
      $err[] = "Логин может состоять только из букв английского алфавита и цифр";
    }

    if(strlen($_POST['login']) < 3 or strlen($_POST['login']) > 30) {
      $err[] = "Логин должен быть не меньше 3-x символов и не больше 30";
    }

    $sql = "
    SELECT COUNT(user_id) 
    FROM users 
    WHERE user_login='".mysql_real_escape_string($_POST['login'])."'
    ";

    $query = mysqli_query($link,$sql);

    if(mysqli_result($query, 0) > 0) {
      $err[] = "Пользватель с таким логином уже существует в базе данных";
    }

    if(count($err) == 0) {
      $login = $_POST['login'];
      $password = md5(md5(trim($_POST['password'])));

      $sql = "
        SELECT COUNT(user_id) 
        FROM users 
        WHERE user_login='".mysql_real_escape_string($_POST['login'])."'
      ";

      mysqli_query($link,$sql);

      header("location: login.php"); exit();
    }else {
      print "<b>При регистрации произошли следующие ошибки: </b><br>";

      foreach($err AS $error) {
        print $error . "<br>";
      }
    }
  }
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eskrano, 2015-10-08
@HeartOfProgrammer

you don't have<form , а <from

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question