**Файл registration.php
**<h2>Регистрация </h2>
<form action="registration.php" id="form_login" method="POST">
<input type="text" name="name"maxlength="16" placeholder="Введите имя" required> <br>
<input type="text" name="phone" minlength="11" maxlength="11" placeholder="Введите номер (7xxx...) " required> <br>
<input type="email" name="email" placeholder="Введите e-mail" maxlength="50" required> <br>
<input type="password" name="password" placeholder="Введите пароль" minlength="8" maxlength="16" required> <br>
<input type="password" name="password2" placeholder="Повторите пароль" minlength="8" maxlength="16" required> <br>
<input type="submit" class="button_registration" value="Регистрация">
</form>
<?php
if (isset($_POST['name']) && isset($_POST['phone']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['password2'])) {
if ($_POST['password'] == $_POST['password2']) {
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$sql = mysqli_query($connect, "INSERT INTO `users` (`name`, `phone`, `email`, `password`) VALUES ('$name', '$phone', '$email', md5($password))");
echo '<div class="good"> Пользователь успешно добавлен <br>
<a href="join.php">Войти </a> </div> ';
}
else {
echo 'Пароли не совпадают';
}
}
?>
файл обработчик входа
**<html>
<meta charset="utf-8">
</html>
<?php
session_start();
require_once 'connect.php';
if (isset($_POST['phone']) && isset($_POST['password'])) {
$phone = filter_var(trim($_POST['phone']), FILTER_SANITIZE_STRING);
$password=$_POST['password'];
$passwordmd5 = md5($password);
$query = "SELECT *FROM `users` WHERE `phone`='{$phone}' AND `password`='{$passwordmd5}' LIMIT 1";
$sql = mysqli_query($connect, $query) or die(mysqli_error());
if (mysqli_num_rows($sql) == 1) {
$result = mysqli_fetch_assoc($sql);
$_SESSION['id'] = $result['id'];
$_SESSION['per'] = $result['per'];
$_SESSION['phone'] = $result['phone'];
$_SESSION['name'] = $result['name'];
$sql = mysqli_query($connect, "INSERT INTO events (text,phone) VALUES ('Попытка входа: удачный вход','{$_SESSION['phone']}')");
if ($_SESSION['per']=="user") {
echo "<script>window.location.href='lk.php'</script> ";
echo 'Привет '.$_POST['login'].', права user';
}
if ($_SESSION['per']=="admin") {
echo "<script>window.location.href='admin.php'</script> ";
echo 'Привет '.$_POST['login'].', права user';
}
}else {
$sql = mysqli_query($connect, "INSERT INTO events (text,phone) VALUES ('Попытка входа: неудачный вход','{$_POST['phone']}')");
echo'Неверное имя пользователя или пароль';
}
}
?>**
Файл Join.php
<?php
require_once 'connect.php';
session_start();
?>
<h2>Войдите в аккаунт </h2>
<form action="add.php" method="POST">
<input type="text" id="fvxod" name="phone" minlength="11" maxlength="11" placeholder="Введите номер (7xxx)"> <br>
<input type="password" id="fvxod" name="password" maxlength="16" placeholder="Введите пароль"> <br>
<input type="submit" id="svxod" value="Войти"> <br>
<input type="button" value="Регистрация" onclick="window.location.href='registration.php'">
</form>
</div>
</div>
</body>
</html>**
файл connect.php
**<?php
$host = 'localhost';
$user = 'borhimnj';
$pass = '';
$db_name = 'bor`введите сюда код`himnj';
$connect = mysqli_connect($host, $user, $pass, $db_name);
if (!$connect) {
die("Ошибка подключения: " . mysqli_connect_error());
}
?>**
Использую хостинг Beget**