can't display username in redirect page
Posted: Wed Jun 27, 2007 6:09 am
i cannot display logged user name's in the redirect page( index_grant.php). i think this is a session problem according my little knowledge. can anyone give me a solution for this. [s]pls[/s] please.
here are [s]da[/s] the codes
index.php
in this page get username & password and pass it to 1.php
in 1.php
in this check the user and redirected to index_grant.php
in index_grant.php
logout & display username
if need any clarification [s]pls[/s] please post.
[s]tnx[/s] thanks
nilupa.
here are [s]da[/s] the codes
index.php
in this page get username & password and pass it to 1.php
Code: Select all
<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
include("config.php");
echo "<form method='post' action='1.php'><table border='0' width='80%' id='table4'>";
echo "<tr><td><strong>Username</strong></td><td width='50%'><input type='username' style='width:97px; height:18px; font-family:tahoma; font-size:11px ' name='username' size='20'></td></tr>";
echo "<tr><td><strong>Password</strong></td><td><input type='password' style='width:97px; height:18px; font-family:tahoma; font-size:11px ' name='password' size='20' ><input name='go' type='image' src='images/go.jpg' align='top' style='margin-left:7px'</td></tr>";
echo "</table></form>";
?>in 1.php
in this check the user and redirected to index_grant.php
Code: Select all
<?php
include("config.php");
/*$callback="index_grant.php?err=#error#";
$callback .= "$name=".urlencode($_REQUEST["username"]);*/
$_user_name = $_POST['username'];
$_password = $_POST['password'];
//check the login
mysql_connect($host, $user_name, $password)
or die('Could not connect: ' . mysql_error());
//select database
mysql_select_db($database_name) or die('Could not select database');
$result = mysql_query("SELECT * FROM users WHERE username='$_user_name'") or die(mysql_error());
$row = mysql_fetch_array( $result );
if($row['username'] == '')
{
echo "<b> Username or Password is incorrect. <a href='index.php' class='red'> [Go Back]</a></b>";//<br>";
}
else
{
if($row['password'] == $_password)
{
$_SESSION['logged'] = "agk8gjf38834j2";
$_SESSION['user'] = $_user_name;
$name=$row['username'];
//echo($name);
header("location:" . 'index_grant.php');
//header("1.php");
}
else
{
echo "<b> Username or Password is incorrect. <a href='index.php' class='red'> [Go Back]</a></b>";//<br>";
}
//session_destroy();
}
?>in index_grant.php
logout & display username
Code: Select all
<?php
include("config.php");
//echo($_REQUEST[$seuser]);
$_SESSION['user'];
$username=$_SESSION['user'];
//echo ;
/*?>if($_SESSION['logged'] != 'agk8gjf38834j2')
{
header("location:" . $_login_file);
} */
echo "<div style='margin-top:20px'><div style='margin-left:10px'><b> Welcome, You are Logged in| <a href='logout.php' class='red'>log out [ administrator$username ]</a></b></div></div>";
//session_destroy();
?>if need any clarification [s]pls[/s] please post.
[s]tnx[/s] thanks
nilupa.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.