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.";
}
}
?>
<form method="post" action="<?php htmlspecialchars("PHP_SELF", ENT_QUOTES,"UTF-8"); ?>">
<label>Korisničko ime:</label><input type="text" name="klij_ime"></br>
<label>Lozinka:</label><input type="password" name="klij_sifra"></br>
<br/>
<input type="submit" value="submit"></br>
</form>
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!
|