Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the quiz-master-next domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /data01/virt105257/domeenid/www.blinov20.thkit.ee/htdocs/wp/wp-includes/functions.php on line 6131
Login ja logout – Georgi Blinov Õpimapp

Login ja logout

  1. Uus veebileht vorm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if(isset($_POST['login']) and isset($_POST['password'])){
    $login = $_POST['login'];
    $password = $_POST['password'];
    if ($login == 'admin' and $password == '1234'){
        $_SESSION['tuvastamine']='niilihtne';
        header('Location: ./puud.php');
    } else {
        echo "Invalid password.";
    }
}
<h1>Login vorm</h1>
<form action="" method="POST">
    Login:
    <input type="text" name="login" placeholder="username"><br>
    Parool:
    <input type="password" name="password"><br>
    <input type="submit" value="Logi sisse">
</form>

2. Veebilehel milles login

1
2
3
4
5
session_start();
if(!isset($_SESSION['tuvastamine'])) {
    header('Location: ./login.php');
    exit();
}

3. Logout

1
2
3
4
5
6
7
8
9
<?php
session_start();
if (isset($_POST['logout'])){
    session_unset();
    session_destroy();
    header('Location: login.php');
    exit();
}

CREATE TABLE kasutajad(
id int not null PRIMARY KEY AUTO_INCREMENT,
nimi varchar(10),
parool varchar(200),
onAdmin tinyint,
koduleht varchar(100))