Answer the question
In order to leave comments, you need to log in
Why are errors popping up?
The problem is this, I made a registration form, created a database, posted it on an open server. Everything works, the data is entered into the database.
Then I uploaded it to the hosting, entered the data of my database and decided to check again. And then there are errors. I searched for solutions to problems, but did not find it.
Here is the code
<?php
if($_COOKIE['user'] == ''):
?>
<div class="row">
<div class="col">
<h1>Форма регистрации</h1>
<form action="validation-form/check.php" method="POST">
<input type="text" class="form-control" name="login" id="login" placeholder="Введите логин"><br>
<input type="text" class="form-control" name="name" id="name" placeholder="Введите имя"><br>
<input type="password" class="form-control" name="pass" id="pass" placeholder="Введите пароль"><br>
<button class="btn btn-success" type="submit">Зарегистрировать</button>
</form>
</div>
<?php else: ?>
<p>Привет <?=$_COOKIE['user']?>. Чтобы выйти нажмите <a href="/exit.php">здесь</a>.</p>
<?php endif;?>
<?php
$login = filter_var(trim($_POST['login']),
FILTER_SANITIZE_STRING);
$name = filter_var(trim($_POST['name']),
FILTER_SANITIZE_STRING);
$pass = filter_var(trim($_POST['pass']),
FILTER_SANITIZE_STRING);
if(mb_strlen($login) < 5 || mb_strlen($login) > 90 ) {
echo "Недопустимая длина логина";
exit();
} else if(mb_strlen($name) < 3 || mb_strlen($name) > 50 ) {
echo "Недопустимая длина имени";
exit();
} else if(mb_strlen($pass) < 5 || mb_strlen($pass) > 16 ) {
echo "Недопустимая длина пароля (от 5 до 16 символов)";
exit();
}
$pass = md5($pass."dfdfsdfsdfdsf");
require "blocks/connect.php";
$mysql->query("INSERT INTO `users` (`login`, `pass`, `name`) VALUES('$login', '$pass', '$name')");
$mysql->close();
?>
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