<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/style.min.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>Регистрация</h1>
<form action="reg.php" method="post">
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Логин</label>
<input type="text" class="form-control" id="exampleInputEmail1" name="login">
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Пароль</label>
<input type="password" class="form-control" id="exampleInputPassword1" name="password">
</div>
<div class="mb-3">
<label for="exampleInputPassword2" class="form-label">Повторите пароль</label>
<input type="password" class="form-control" id="exampleInputPassword2" name="passwordConfirm">
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Запомнить</label>
</div>
<button type="submit" class="btn btn-primary">Зарегистрироваться</button>
<br>
<p>
<?php
echo $_SESSION['msg'];
unset($_SESSION['msg']);
?>
</p>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</body>
</html>
<?php
session_start();
require_once 'connect.php';
$login = $_POST['login'];
$password = $_POST['password'];
$passwordConfirm = $_POST['passwordConfirm'];
if($password === $passwordConfirm){
$query = "INSERT INTO `users` (`login`, `password`, `password__confirm`) VALUES (:login, :password, :password__confirm)";
$params = [
':login' => $login,
':password' => $password,
':password__confirm' => $passwordConfirm
];
$stmt = $db->prepare($query);
$stmt->execute($params);
header("Location: lc.php");
}
else{
$_SESSION['msg'] = "Пароли не совпадают";
header("Location: index.php");
};
?>