I wanna showing the user name in every page when they are s successfully login to the page .But dun knoe why it cannot work~~
This is for login page ~~
<?php require_once('../../../Connections/admin_db.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "level";
$MM_redirectLoginSuccess = "Index.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_admin_db, $admin_db);
$LoginRS__query=sprintf("SELECT user_name, password, level FROM login WHERE user_name=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $admin_db) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'level');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
$currentPage = $_SERVER["PHP_SELF"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by NodeThirtyThree <http://www.nodethirtythree.com>
Published by Free CSS Templates <http://www.freecsstemplates.org/>
Released for free under a Creative Commons Attribution 2.5 License
Title : snowglass
Version : 1.0
Released : 20070718
Description: A two-column, fixed-width template featuring a blue glass effect ideal for 1024x768 resolutions.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin-Program List</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="file:///C|/Users/shayfen/Desktop/snowglass/default.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:651px;
height:300px;
z-index:1;
left: 248px;
top: 249px;
background-color: #333333;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #FFF;
border-right-color: #FFF;
border-bottom-color: #FFF;
border-left-color: #FFF;
color: #FFF;
}
#apDiv2 {
position:absolute;
width:643px;
height:26px;
z-index:1;
top: 6px;
color: #FFF;
font-size: 24px;
text-align: center;
border-top-style: groove;
border-right-style: groove;
border-bottom-style: groove;
border-left-style: groove;
border-top-color: #FFF;
border-right-color: #FFF;
border-bottom-color: #FFF;
border-left-color: #FFF;
left: 3px;
background-color: #666666;
}
#apDiv3 {
position:absolute;
width:595px;
height:188px;
z-index:2;
left: 182px;
top: 121px;
background-color: #666666;
border-top-style: double;
border-right-style: double;
border-bottom-style: double;
border-left-style: double;
border-top-color: #FFF;
border-right-color: #FFF;
border-bottom-color: #FFF;
border-left-color: #FFF;
color: #666;
}
#apDiv4 {
position:absolute;
width:742px;
height:44px;
z-index:2;
left: 212px;
top: 268px;
}
.a {
font-size: 18px;
}
.w {
font-size: 14px;
}
#apDiv1 #apDiv3 table tr {
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #FFF;
border-right-color: #FFF;
border-bottom-color: #FFF;
border-left-color: #FFF;
color: #000;
}
#apDiv1 #apDiv3 table tr {
background-color: #FFF;
color: #FFF;
}
#apDiv1 #apDiv3 table {
font-family: Georgia, "Times New Roman", Times, serif;
color: #999;
background-color: #999;
}
-->
</style>
<style type="text/css">
<!--
#apDiv5 {
position:absolute;
width:382px;
height:112px;
z-index:3;
left: 198px;
top: 32px;
background-color: #666666;
}
#apDiv1 #apDiv3 #apDiv5 #form1 table tr td {
font-size: 18px;
}
#apDiv1 #apDiv3 #apDiv5 #form1 table tr td1 {
color: #666;
}
#apDiv6 {
position:absolute;
width:604px;
height:183px;
z-index:3;
left: 5px;
top: 7px;
}
#apDiv1 #apDiv3 #form1 #apDiv6 table tr td {
font-size: 18px;
}
#apDiv7 {
position:absolute;
width:573px;
height:212px;
z-index:2;
left: 209px;
top: 137px;
background-color: #666666;
color: #666;
}
#apDiv8 {
position:absolute;
width:337px;
height:122px;
z-index:1;
left: 134px;
top: 51px;
}
.j {
border-top-color: #FFF;
border-right-color: #FFF;
border-bottom-color: #FFF;
border-left-color: #FFF;
}
#apDiv9 {
position:absolute;
width:551px;
height:207px;
z-index:2;
left: 422px;
top: 196px;
background-color: #33FF66;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #FFF;
border-right-color: #FFF;
border-bottom-color: #FFF;
border-left-color: #FFF;
font-size: 18px;
text-align: center;
color: #D6D6D6;
}
#apDiv1 #apDiv9 #form1 table trk {
border-top-style: dotted;
border-right-style: dotted;
border-bottom-style: dotted;
border-left-style: dotted;
border-top-color: #D6D6D6;
border-right-color: #D6D6D6;
border-bottom-color: #D6D6D6;
border-left-color: #D6D6D6;
}
#apDiv1 #apDiv9 #form1 table tr td {
text-align: left;
}
#apDiv1 #apDiv9 #form3 table tr {
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #FFF;
border-right-color: #FFF;
border-bottom-color: #FFF;
border-left-color: #FFF;
}
#apDiv10 {
position:absolute;
width:527px;
height:136px;
z-index:3;
left: 7px;
top: 30px;
}
#apDiv1 #apDiv9 #form3 #apDiv10 table tr td {
color: #FFF;
font-size: 16px;
font-weight: bold;
}
#apDiv1 #apDiv9 #p_list table {
text-align: center;
}
#apDiv1 #apDiv9 #p_list a strongk {
color: #FFF;
}
#apDiv1 #apDiv9 #p_list a strongo {
color: #CCC;
}
body,td,th {
color: #FFF;
font-size: 14px;
font-weight: bold;
}
#apDiv1 #apDiv9 #p_list a strong {
background-color: #FFF;
}
.xx {
font-family: Courier New, Courier, monospace;
}
#apDiv1 #apDiv9 #p_list table tr tdw {
color: #F00;
}
a:link {
color: #FFF;
text-decoration: underline;
}
#apDiv11 {
position:absolute;
width:303px;
height:59px;
z-index:3;
left: 225px;
top: 246px;
}
body {
background-color: #F4FFFF;
}
a:hover {
color: #FF0;
text-decoration: underline;
}
a:visited {
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
#apDiv12 {
position:absolute;
width:648px;
height:24px;
z-index:3;
left: 87px;
top: 351px;
color: #FF6;
text-align: right;
}
#apDiv1 #apDiv12s {
text-align: center;
}
#apDiv1 #apDiv12w {
text-align: center;
}
.s {
font-weight: bold;
font-size: 14px;
}
#apDiv13 {
position:absolute;
width:163px;
height:125px;
z-index:2;
left: -241px;
top: -1px;
}
#apDiv14 {
position:absolute;
width:117px;
height:134px;
z-index:2;
left: 71px;
top: 88px;
}
#apDiv15 {
position:absolute;
width:354px;
height:158px;
z-index:3;
left: 208px;
top: 68px;
}
#apDiv1 #apDiv15 #passForm table tr td font5 {
font-size: 16px;
}
#apDiv1 #apDiv15 #passForm table tr td fontu {
font-size: 16px;
}
#apDiv1 #apDiv15 #passForm table tr td font6 {
font-size: 16px;
}
#apDiv16 {
position:absolute;
width:342px;
height:115px;
z-index:3;
left: 248px;
top: 94px;
}
#apDiv17 {
position:absolute;
width:359px;
height:143px;
z-index:3;
left: 229px;
top: 91px;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function savePass(nameusr,namepwd,valueusr,valuepwd,days) {
var message = "";
if (document.passForm.username.value == "" || document.passForm.password.value == "") {
message = "Please insert both Username and Password.";
}
if (message.length > 0) {
alert(message);
return false;
} else
if (document.passForm.savepass.checked == true) {
var time = new Date(Date.parse(Date()) + 86400000*days);
document.cookie = nameusr + "=" + escape(valueusr) + "; expires=" + time.toUTCString();
document.cookie = namepwd + "=" + escape(valuepwd) + "; expires=" + time.toUTCString();
} else {
document.cookie = nameusr + "=" + "" + "; expires=Thu,01-Jan-70 00:00:01 UTC";
document.cookie = namepwd + "=" + "" + "; expires=Thu,01-Jan-70 00:00:01 UTC";
}
}
function getCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var endstr = document.cookie.indexOf(";", j);
if (endstr == -1) endstr = document.cookie.length;
return unescape(document.cookie.substring(j, endstr));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return "";
}
function getPass(nameusr,namepwd) {
if (getCookie(namepwd) != "undefined" && getCookie(namepwd) != "") {
document.passForm.username.value = getCookie(nameusr);
document.passForm.password.value = getCookie(namepwd);
document.passForm.savepass.checked = true;
}
}
//-->
</script>
</head>
<body bgcolor="#D6D6D6">
<div id="header">
<div id="logo"></div>
<img src="../images/img02.jpg" alt="" width="954" height="183" /></div>
<hr />
<p> </p>
<p> </p>
<div id="apDiv1" onload="getPass('cuser','cpass')">
<div id="apDiv2"> >>User Login<<</div>
<div id="apDiv14"><img src="../images/1300369977_preferences-desktop-user-password.png" alt="" width="110" height="132" /></div>
<form method="post" id="passForm">
</form>
<div id="apDiv17" onload="getPass('cuser','cpass')">
<form ACTION="<?php echo $loginFormAction; ?>" method="POST" id="passForm">
<table width="356" height="115" border="2" cellpadding="2" cellspacing="2">
<tr>
<td><font face="Arial" size="2">Username:</font></td>
<td colspan="2"><input type="text" name="username" /></td>
</tr>
<tr>
<td><font face="Arial" size="2">Password:</font></td>
<td colspan="2"><input type="password" name="password" /></td>
</tr>
<tr>
<td><font face="Arial" size="2"> </font></td>
<td><input name="savepass" type="checkbox" value="true" onclick="return savePass('cuser','cpass',username.value,password.value,30)" />
<font face="Arial" size="1">Save Pass</font></td>
<td align="right"><input type="submit" name="Submit" value="Enter" onclick="return savePass('cuser','cpass',username.value,password.value,30)" /></td>
</tr>
</table>
</form>
</div>
</div>
<p> </p>
<p> </p>
<p> </p>
<p>
<!-- end page -->
</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<hr />
</body>
</html>