-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.php
31 lines (26 loc) · 898 Bytes
/
auth.php
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
<?php
require "db.php";
if(isset($_POST["name"]) and isset($_POST["password"])){
$name = $_POST["name"];
$password =$_POST["password"];
global $db;
$log = "SELECT * FROM users WHERE Name = '$name' and password = '$password'";
$result = $db->prepare($log);
$result->execute();
$count = $result->fetchColumn();
if($count >= 1){
$_SESSION['name'] = $name;
$_SESSION['password'] = $password;
}else
{
$error = "ошибка";
}
if(isset($_SESSION['name'])){
// echo'<script> window.location="index.php"; </script> ';
header("Location: index.php");
}else
{
echo 'Неверный логин или пароль';
echo "<a href='index.php'>Вернуться</a>";
}
}