Forum Moderators: coopster

Message Too Old, No Replies

need to dispaly the User name in all pages

I need to display the User name in all the pages when User logged in correc

         

ravii

12:05 pm on Sep 11, 2008 (gmt 0)

10+ Year Member



Hello,,

Can any one help me out

I need to display the User name in all the pages when User logged in correctly

my problem is for the first time it is showing the Username and when i click on the 1 or 2 or 3 in the navigation bar paging ( [prev] 1 2 3... [next]) then i can't see the user name in the style.php

here is my login page

<table>
<tr><h3 align="left"><font color="CadetBlue"><b></b> Sign In </b></font></h3></tr>
</table>
<form name="connect" method= "POST">
<table>
<th><font color="CadetBlue"> <b> Access Account : </b></font></th>
<tr></tr>
<tr><td><font align="right"color="CadetBlue"><b> UserName: </b> </font></td>
<td><input type="text" name="cname"></br></td>
<td>
<?php
if (isset($_POST['checkme']))
{
$cusername=$_POST['cname'];
$cpassword=$_POST['cpass'];
$check=IsEmpty($cusername,$cpassword);
if ($check>0)
{
$c=connect();
$query = "SELECT user_id,password FROM users where user_id='".$cusername."' AND password='".$cpassword."'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
if (mysql_num_rows($result) > 0)
{
global $cusername;
// echo "<font size='4' face='Garamond' color='white'><b> You have Successfully logged In </b></font> </br>";
header("Location:stl.php?uname=".$cusername);
//echo "<a href='stl.php?uname=$cusername'> </a>";

}
else
{
echo "<font size='4' face='Garamond' color='white'><b>Oouchh.. you failed to Log In </b></font> </br>";
}
}
}
?>
</td>
</tr>
<tr><td><font color="CadetBlue"><b> Password:</b> </font></td>
<td><input type="password" name="cpass"></td>
<td><input type="submit" value="Sign In" name="checkme">
</td>
</tr>
</form>
<form action="newaccount.php" method= "POST">
<tr></tr>
<tr>
<td align="left"><font color="CadetBlue"> <b>New Account </b> </td>
<td><input type="submit" value="Sign Up"></font></td>
</tr>
</table>
</form>
<form method=POST action="forgot.php">
<table>
<tr></tr>
<tr><td><font color="CadetBlue"><b>Forgot Password: </b></font></td>
<td><a href="forgot.php"> <font color="blue">Click Here </font></a></td></tr>
</form>
<form action="stylesupload.php" method= "POST">
<tr></tr><tr></tr>
<tr><td><font color="CadetBlue"><b>Styles Upload: </b></font></td>
<td><a href="stylesupload.php"> <font color="blue">Click Here </font></a></td>
</tr>
</form>
</table>

----------------------------------------------------------
here is my style.php

<?php
$c=connect();
$page_name="style.php";
$start=$_GET['start'];
if(!($start>0))
{
$start=0;

}

//if (!isset($cuser))
//{
//global $cuser;
//$cuser=$_GET['uname'];
//echo $cuser;
//}

$eu=($start-0);
$limit=9;
$this1=$eu+$limit; //6
$back=$eu-$limit; //-6
$next=$eu+$limit; //6
$query2="select img_name from styles";
$sql=mysql_query($query2);
$result2=mysql_num_rows($sql); //20
$query="select img_name from styles limit $eu,$limit"; //0 to 6
$result=mysql_query($query);

$cuser=$_GET['uname'];

echo "<table align='right'><tr><td align='right' width='14%'><font face='Monotype Corsiva' size='5' color='Red'>User:</font></td>
<td align='left'width='1%'><font face='Monotype Corsiva' size='5' color='blue'>" .$cuser."</font></td></tr></table>";

echo '<table border="5" align="center" width="55%" height="60%" BORDERCOLOR="#C6C6C6" >';
for($r=1;$r<=3;$r++)
{
echo '<tr>';
for($d=1;$d<=3;$d++)
{
$obj=mysql_fetch_object($result);
$imageSrc=$obj->img_name;
$cimage="images/".$obj->img_name;
echo '<td border="1" width="25px" height="25px" name="img1"><a href="img.php?src='.$imageSrc.'"><img width="187px" height="109px" src='.$cimage.'></a></td>';
}
echo '</tr>';
}
echo '</table>';
$nume=$result2;

if($nume > $limit )
{
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
if($back >=0)
{
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>";
}
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit)
{
if($i <> $eu)
{
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else
{
echo "<font face='Verdana' size='4' color=red>$l</font>";
}
$l=$l+1;
}
echo "</td><td align='right' width='30%'>";
if($this1 < $nume)
{
print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";
}
echo "</td></tr></table>";
}
?>

thanks in advance

d40sithui

9:43 pm on Sep 11, 2008 (gmt 0)

10+ Year Member



i dont see anything to maintain state in your code.
have you consider sessions for this purpose?

IndiaMaster

4:39 am on Sep 12, 2008 (gmt 0)

10+ Year Member



You can try by putting the Username in a session variable and echoing it on every page where ever you require to display that.