html head title БД title head body div h4 php if isset output echo out

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<html>
<head>
<title>БД</title>
</head>
<body>
<div>
<h4> <?php if(isset($output)) echo $output?> </h4>
<form action="index.php" align="center" method="post">
<br><br>
<input type="text" name="login" placeholder="Логин" autocomplete="on">
<br>
<input type="password" name="password" placeholder="Пароль">
<br><br><br>
<button type="submit">Войти</button>
</form>
</div>
</body>
</html>
<?php
session_start();
session_destroy();
if (!isset($_POST['login']))
{
include 'auth_form.php';
exit();
}
if (isset($_POST['login']))
{
$log = "fik";
$pas = "fik";
include 'dbconnectauth.php';
$log = $_POST['login'];
$pas = $_POST['password'];
$sql = "SELECT U_gr_login, U_gr_password FROM users WHERE U_login = '$log' AND U_password = '$pas';";
include 'dbselect.php';
if($result -> rowCount() != 1)
{
unset($_POST['login']);
$output = 'Неверный логин или пароль';
include 'auth_form.php';
exit();
}
else
{
$string = $result -> fetch();
$log = $string['U_gr_login'];
$pas = $string['U_gr_password'];
session_start();
$_SESSION['login'] = $log;
$_SESSION['password'] = $pas;
header('Location: ../index.php');
exit();
}
}
?>