Reply to session problem

Your name:

Reply:


Posted by Rtenboer@gmail.com on 08/16/07 09:58

Hello to all again :)

i have a problem with a session
this is my index page what will check if you are logged in or not if
you are logged in it should be displaying the session username
<?php
if(!isset($_SESSION["logged"]))
{
echo "<div id=\"Display\">";
echo "je bent niet ingelogd";
echo "</div>";
}
else
{
echo "<div id=\"Display\">";
echo "welkom : ".$_SESSION["username"]."";
echo "</div>";
}
?>
my login page
<?php
session_start();
$user = addslashes($_POST['username']);
$pass = md5($_POST['password']);
$db = mysql_connect('localhost', 'mysqluser', mysqlpassword') or die
(mysql_error());
mysql_select_db("cms", $db);
if(isset($_POST['submit']))
{
$sql = "select * from users where username = '".$user."' and password
= '".$pass."'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_fetch_assoc($res) > 1)
{
$username = $_POST['username'];
$password = md5($_POST['password']);
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
$_SESSION["logged"] = 'true';
header('location: index.php');
}
}


?>
well once i try to login it will redirect me to the index.php what is
correct
but now its should tell me on the index page what user is logged but
that isn't happening
anyone know what i did wrong?
greetings

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация