i want to create 1 page that when diffrent user log in, it show a data from that user table have log in.i have 2 table user,1 session variable., and 2 recordset
it is my code:
<?php require_once('Connections/repi.php'); ?>
<?php
$colname_user_admin = "1";
if (isset($_SESSION['MM_Username'])) {
$colname_user_admin = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_repi, $repi);
$query_user_admin = sprintf("SELECT * FROM `admin` WHERE USERNAME = '%s'", $colname_user_admin);
$user_admin = mysql_query($query_user_admin, $repi) or die(mysql_error());
$row_user_admin = mysql_fetch_assoc($user_admin);
$totalRows_user_admin = mysql_num_rows($user_admin);
$colname_user_guru = "1";
if (isset($_SESSION['MM_Username'])) {
$colname_user_guru = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_repi, $repi);
$query_user_guru = sprintf("SELECT * FROM guru WHERE USERNAME = '%s'", $colname_user_guru);
$user_guru = mysql_query($query_user_guru, $repi) or die(mysql_error());
$row_user_guru = mysql_fetch_assoc($user_guru);
$totalRows_user_guru = mysql_num_rows($user_guru);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
-->
</style></head>
<body>
<div align="left">
<table width="104%" border="0" cellpadding="0" cellspacing="0" background="image/backdot.gif" class="tcat">
<tr>
<td><div align="center"></div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center"></div></td>
</tr>
<tr>
<?php if ($user_admin) { ?>
<td><div align="center"><img src="<? echo "daftar/gambar/",$row_user_admin['PIC']; ?>" width="60" height="80"><br>
</div></td>
</tr>
<tr>
<td><div align="center">
<? echo $row_user_admin['NAMA']; ?>
</div></td>
</tr>
<tr>
<td><div align="center"><?php echo $row_user_admin['JAWATAN']; ?></div></td>
</tr>
<tr>
<td><div align="center">Update Profil </div></td>
</tr>
<tr>
<td><div align="center">Menu Tambahan </div></td>
</tr>
<tr>
<? } else if($user_guru){ ?>
<td><div align="center"><img src="<? echo "daftar/gambar/",$row_user_guru['PIC']; ?>" width="60" height="80" /></div></td>
</tr>
<tr>
<td><div align="center"><?php echo $row_user_guru['NAMA']; ?></div></td>
</tr>
<tr>
<td><div align="center"><?php echo $row_user_guru['JAWATAN']; ?></div></td>
</tr>
<tr>
<td><div align="center">Update Profil </div></td>
</tr>
<tr>
<td><div align="center"><a href="untitled.php">Menu Tambahan</a> </div></td>
</tr>
<? } else {} ?>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
<
</tr>
<?
if (isset($_SESSION['MM_Username']))
{
$log = "Logout";
$linkLog = "logout.php";
}
else
{
$log = "Login";
$linkLog = "login.php"; }
?>
<tr>
<td><div align="center"><a href="<? echo $linkLog ?>"> <? echo $log ?></a></div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center"></div></td>
</tr>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($user_admin);
mysql_free_result($user_guru);
?>
my code is failed to show to user data
it show just from admin table
when user not log in, the pic is still have in this page
please help me... 🙂