D
D
Donald2015-12-19 18:16:17
PHP
Donald, 2015-12-19 18:16:17

One field in the database remains let, what's wrong?

I am new to php, the problem is that when registering in the names field, it does not write to the database, help me with what is the error?

mysql_connect("localhost", "root", "") or die("ошибка");
mysql_select_db("reg");
    if (isset($_POST)) {
       $names= $_POST['names'];
       $login = $_POST['login'];
       $pass = md5($_POST['password']);
       $email = $_POST['email'];
       $query = mysql_query("SELECT * FROM registr WHERE login='$login' OR email='$email'") or die("ошибка");
       $user_data = mysql_fetch_array($query);
       if($user_data['login'] == $login || $user_data['email'] == $email) {
           echo "логин или email уже существует";

       } 
       else {
           $query = mysql_query("INSERT INTO registr VALUES ('', '$names', '$login', '$pass', '$email')") or die("ошибка");
           echo 'Вы успешно зарегистрировались!';
       }
    }

<input type="text" name="names" class="names" required="" placeholder="Имя">
<input type="text" name="login" class="login" required="" placeholder="Логин">
<input type="password" name="password" class="password" required="" placeholder="Пароль">
<input type="email" name="email" class="email" required="" placeholder="Емаил">
<button id="reg">Регистрация</button>

DB structure
id int(11) AUTO_INCREMENT
names varchar(250) utf8_general_ci
login varchar(250) utf8_general_ci
password varchar(250) utf8_general_ci
email varchar(250)
utf8_general_ci than the problem

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robot, 2015-12-19
Duck @Don_Donald

Why is this before names?
'',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question