Session and member profile

Pokusavam da pomocu sesije mi pokaze podatke o korisniku u korisnickom profilu, ali jednostavno to ne uspevam (priznajem, ne znam). Molim vas za pomoc, bila bi mi dobrodosla.

login_klij.php (radi)

<?php session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { //if(isset($_POST['username'])){ $username=htmlspecialchars($_POST['klij_ime'],ENT_QUOTES,"UTF-8"); //} //if(isset($_POST['password'])) //{ $password=htmlspecialchars($_POST['klij_sifra'],ENT_QUOTES,"UTF-8"); //} //connect to database $con=mysqli_connect("localhost","root","123","stampa") or die(); //execute query $query ="SELECT * FROM `klijenti` WHERE klij_ime='$username'and klij_sifra='$password' "; $result=mysqli_query($con, $query); while($row = mysqli_fetch_array($result)) if($_POST['klij_ime']==$row['klij_ime'] && $_POST['klij_sifra']==$row['klij_sifra'] ) { $_SESSION['klij_ime']=$username; $_SESSION['naziv_firme']=$password; header("Location:dashboard_klij.php"); } else { echo "Pogrešno korisničko ime i/ili lozinka."; } } ?> ">

Korisničko ime:
Lozinka:


dashboard_klij.php (ne radi)

<?php session_start(); $con=mysqli_connect("localhost","root","123","stampa") or die(); echo "Dobrodošli, ". $_SESSION['klij_ime']; echo "Naziv firme:". $_SESSION['naziv_firme']; $result = mysqli_query($con, "SELECT naziv_firme klijenti where naziv_firme=$naziv_firme "); ?>

Baza sadrzi naziv firme pored korisnickog imena i sifre. Hvala unapred!

login.php
<?php
session_start();

if ($_POST) {
    $username = htmlspecialchars($_POST['klijime'], ENT_QUOTES, "UTF-8");
    $password = htmlspecialchars($_POST['klijsifra'], ENT_QUOTES, "UTF-8");
    $con = mysqli_connect("localhost", "root", "123", "stampa") or die();

    $query = "SELECT * FROM klijenti WHERE klij_ime='$username'and klij_sifra='$password' ";
    $result = mysqli_query($con, $query);
    while ($row = mysqli_fetch_array($result))
        if ($_POST['klijime'] == $row['klij_ime'] && $_POST['klijsifra'] == $row['klij_sifra']) {
            $_SESSION['klijime'] = $username;
            $_SESSION['nazivfirme'] = $password;
            header("Location:dashboard_klij.php");
        } else {
            echo "Pogrešno korisničko ime i/ili lozinka.";
        }
}
?>

dashboard.php

   <?php
    session_start();
    $con = mysqli_connect("localhost", "root", "123", "stampa") or die();
    echo "Dobrodošli, " . $_SESSION['klijime'];
    echo "Naziv firme:" . $_SESSION['nazivfirme'];
    
    $result = mysqli_query($con, "SELECT naziv_firme klijenti where naziv_firme=$naziv_firme ");
    ?>

Ajde probaj sad.

Hvala na brzom odgovoru. Cenim to.
umesto naziva firme prikazuje se ustvari sifra uy\z ovu gresku

Notice: Undefined variable: naziv_firme in D:\wamp\www\Andrej-stamparija\dashboard_klij.php on line 7

Ovo je kod

login_klij.php

<?php session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { //if(isset($_POST['username'])){ $username=htmlspecialchars($_POST['klij_ime'],ENT_QUOTES,"UTF-8"); //} //if(isset($_POST['password'])) //{ $password=htmlspecialchars($_POST['klij_sifra'],ENT_QUOTES,"UTF-8"); //} //connect to database $con=mysqli_connect("localhost","root","123","stampa") or die(); //execute query $query ="SELECT * FROM `klijenti` WHERE klij_ime='$username'and klij_sifra='$password' "; $result=mysqli_query($con, $query); while($row = mysqli_fetch_array($result)) if($_POST['klij_ime']==$row['klij_ime'] && $_POST['klij_sifra']==$row['klij_sifra'] ) { $_SESSION['klij_ime']=$username; $_SESSION['klij_sifra']=$password; header("Location:dashboard_klij.php"); } else { echo "Pogrešno korisničko ime i/ili lozinka."; } } ?> ">

Korisničko ime:
Lozinka:


dashboard_klij.php

<?php session_start(); $con = mysqli_connect("localhost", "root", "123", "stampa") or die(); echo "Dobrodošli, " . $_SESSION['klij_ime']; echo "Naziv firme:" . $_SESSION['naziv_firme']; $result = mysqli_query($con, "SELECT naziv_firme klijenti where naziv_firme=$naziv_firme "); ?>

Nemas definiranu varijablu $naziv_firme

Ne znam gde da je definiram.


Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Profit Monkey