Answer the question
In order to leave comments, you need to log in
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>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question