index.php

Datoteka index.php je glavna datoteka spletne aplikacije.

 

<?php
session_start();
include "funkcije.php";
$prijava = "";
$registracija = "";
$vnos_ocene = "";
$izbris_ocene = "";
if ($_GET["odjava"] != null && $_GET["odjava"] == 1)
{
    $_SESSION["user"] = null;
    $_SESSION["vrsta_uporabnika"] = null;
    $_SESSION["tip_uporabnika"] = null;
    $_SESSION["id_uporabnika"] = null;
    $_SESSION["razred"] = null;
    $_SESSION["id_predmeta"] = null;
    $_SESSION["id_dijaka"] = null;
}
if ($_GET["vnos_ocene"] != null)
{
    $_SESSION["id_dijaka"] = $_GET["id_dijaka"];
    $_SESSION["ocene_edit"] = "insert";
}
if ($_GET["izbris_ocene"] != null)
{
    $_SESSION["id_dijaka"] = $_GET["id_dijaka"];
    $_SESSION["ocene_edit"] = "delete";
}
if ($_GET["preklic"] != null)
{
    $_SESSION["id_dijaka"] = null;
}
if (isset($_POST["Btn_prijava"]))
{
    //preverimo prijavne podatke
    $email = $_POST["email"];
    $geslo = $_POST["geslo"];
    if (Prijava_uspela($email,$geslo))
    {
        $prijava = "uspelo";
        $_SESSION["id_uporabnika"] = Get_podatek_uporabnika($email,$geslo,"id_uporabnika");
        $_SESSION["vrsta_uporabnika"] = Get_podatek_uporabnika($email,$geslo,"vrsta_uporabnika");
        $_SESSION["tip_uporabnika"] = Get_podatek_uporabnika($email,$geslo,"tip_uporabnika");
        $_SESSION["user"] = Get_ime_priimek($_SESSION["id_uporabnika"],$_SESSION["vrsta_uporabnika"]);
        Vpis_prijave($_SESSION["id_uporabnika"]);
    }
    else
    {
        $prijava = "ni uspelo";
    }
}
if (isset($_POST["Btn_register"]))
{
    //registiramo uporabnika
    $ime = $_POST["ime"];
    $priimek = $_POST["priimek"];
    $razred = $_POST["razred"];
    $email = $_POST["email"];
    $geslo = $_POST["geslo"];
    $geslo2 = $_POST["geslo2"];
    $vrsta_uporabnika = $_POST["vrsta_uporabnika"];
    if (Registracija_uspela($email,$geslo,$vrsta_uporabnika,$ime,$priimek,$razred))
    {
        $registracija = "uspelo";
    }
    else
    {
        $registracija = "ni uspelo";
    }
}
if (isset($_POST["btn_shrani_oceno"]))
{
    $ocena = $_POST["ocena"];
    $datum = $_POST["datum"];
    $vrsta_ocene = $_POST["vrsta_ocene"];
    $opomba = $_POST["opomba"];
    $id_profesorja = Get_podatek_tabele($_SESSION["id_uporabnika"],"id_uporabnika","profesorji","id_profesorja");
    if (Shrani_oceno($_SESSION["id_dijaka"],$_SESSION["id_predmeta"],$id_profesorja,$ocena,$datum,$vrsta_ocene,$opomba))
    {
        $vnos_ocene = "uspelo";
    }
    else
    {
        $vnos_ocene = "ni uspelo";
    }
    $_SESSION["id_dijaka"] = null;
}
if (isset($_POST["btn_zbrisi_oceno"]))
{
    $id_ocene = $_POST["izbrana_ocena"];
    if (Zbrisi_oceno($id_ocene))
    {
        $izbris_ocene = "uspelo";
    }
    else
    {
        $izbris_ocene = "ni uspelo";
    }
    $_SESSION["id_dijaka"] = null;
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
    <link rel="stylesheet" href="https://unpkg.com/balloon-css/balloon.min.css">
    <title>Redovalnica</title>
</head>
<body class="bg-light">
    <?php
    include "header.php";
    echo "<div class='container'>";
    if ($prijava != "")
    {
        if ($prijava == "uspelo")
        {
            echo "<div class='mt-3 alert alert-success alert-dismissible fade show' role='alert'>Prijava je bila uspešna.<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";
        }
        else
        {
            echo "<div class='mt-3 alert alert-success alert-dismissible fade show' role='alert'>Napaka pri prijavi!<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";
        }
    }
    if ($registracija != "")
    {
        if ($registracija == "uspelo")
        {
            echo "<div class='mt-3 alert alert-success alert-dismissible fade show' role='alert'>Registracija je bila uspešna.<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";
        }
        else
        {
            echo "<div class='mt-3 alert alert-success alert-dismissible fade show' role='alert'>Napaka pri registraciji!<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";
        }
    }
    if ($vnos_ocene != "")
    {
        if ($vnos_ocene == "uspelo")
        {
            echo "<div class='mt-3 alert alert-success alert-dismissible fade show' role='alert'>Vnos ocene je bil uspešen.<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";
        }
        else
        {
            echo "<div class='mt-3 alert alert-success alert-dismissible fade show' role='alert'>Napaka pri vnosu ocene!<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";
        }
    }
    if ($izbris_ocene != "")
    {
        if ($izbris_ocene == "uspelo")
        {
            echo "<div class='mt-3 alert alert-success alert-dismissible fade show' role='alert'>Izbris ocene je bil uspešen.<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";
        }
        else
        {
            echo "<div class='mt-3 alert alert-success alert-dismissible fade show' role='alert'>Napaka pri izbrisu ocene!<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";
        }
    }
    if ($_SESSION["user"] != null)
    {
        //uporabnik je prijavljen
        switch ($_GET["ukaz"])
        {
            case "redovalnica":
            {
                //redovalnica
                if ($_SESSION["vrsta_uporabnika"] == "profesor")
                {
                    include "redovalnica.php";
                }
                elseif ($_SESSION["vrsta_uporabnika"] == "dijak")
                {
                    include "redovalnica_dijak.php";
                }
                break;
            }
            default:
            {
                include "default.php";
                break;
            }
        }
    }
    else
    {
        //uporabnik ni prijavljen
        switch ($_GET["ukaz"])
        {
            case "register":
            {
                //registracija uporabnika
                include "register.php";
                break;
            }
            default:
            {
                //prijava
                include "login.php";
                break;
            }
        }
    }
    echo "</div>";
    ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
</body>
</html>



Created with an evaluation copy of HelpSmith.
To remove this notice, you should purchase the full version of the product.