Hi all i have this code
(exluding HTML) i made from scratch:
After it gets the data from the form it then validates the login. It then sets the session credentials so the blog knows whether to display the users email what thier email is etc. However after some time the username credential gives out leaving blog entries with a blank username. Why does the username entry remain but everything else stay?PHP Code:<?php
session_start();
$email = $_SESSION['email'];
$showemail = $_SESSION['showemail'];
$loggedin = $_SESSION['loggedin'];
$userlevel = $_SESSION['userlevel'];
$username = $_POST['username'];
$password = $_POST['password'];
$DBuser = '*****_****';
$DBpass = '******';
mysql_connect('*****',$DBuser,$DBpass) or die ("Sorry but I couldnt connect.");
mysql_select_db("*****_*****") or die("I couldnt select the database. It may be missing");
$getUsers = mysql_query("SELECT * FROM `*****` WHERE `username` = '$username' AND `password`='$password' LIMIT 0 , 100;");
$num_Users = mysql_num_rows($getUsers);
if($num_Users == 1){
$_SESSION['loggedin'] = true;
$_SESSION['email'] = mysql_result($getUsers,0,'email');
$_SESSION['$showemail'] = mysql_result($getUsers,0,'showemail');
$_SESSION['$userlevel'] = mysql_result($getUsers,0,'level');
$_SESSION['$username'] = $username;
}
?>
<?
if($_SESSION['loggedin'] == true){
echo("Thanks ". $_SESSION['$username'] ." Your logged in as a ");
echo(mysql_result($getUsers,0,'level'));
} else {
echo("Wrong credentials");
}
?>
I thought it was the Session expiring but i know it cant be because otherwise all of the things would expire and not just one.




Reply With Quote