login.php
1.2 KB
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
<?php
namespace count_form\app\data;
class login
{
protected $name;
protected $password;
function index()
{
if(isset($_POST['name']) && isset($_POST['password'])){
$name = htmlspecialchars($_POST['name']);
$password = htmlspecialchars($_POST['password']);
$check = $this->checkUser($name, $password);
if($check){
$this->regUser();
} else {
header("Location:/count_form.php/?p=login");
}
}
}
function createUser()
{
$this->name = 'form_admin';
$this->password = 'qwerty';
}
function checkUser($name, $password)
{
$this->createUser();
if($this->name = $name){
if($this->password = $password)
{
return true;
} else {
return false;
}
} else {
return false;
}
}
function regUser(){
if(session_id()){
$_SESSION['form_admin'] = true;
} else {
session_start();
$_SESSION['form_admin'] = true;
}
}
}