How do I display current user next to "Welcome"?

Not sure if it's a PHP statement or SQL, obvious beginner here.
I want to display the current username next to Welcome

Try using username: Test, password: password
Second username: Test2 password: password

Please speak slowly and detailed if you have an answer  ;-)
<?php require_once('Connections/PlugASong.php'); ?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}
 
mysql_select_db($database_PlugASong, $PlugASong);
$query_Recordset1 = "SELECT * FROM users";
$Recordset1 = mysql_query($query_Recordset1, $PlugASong) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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>
<title>PluASong.com and Findagreatsong.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- ImageReady Preload Script (indexmain.psd) -->
<script type="text/javascript">
<!--
 
userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
 
function findElement(n,ly) {
	if (browserVers < 4)		return document[n];
	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (!elem) {
		for (var i=0;i<curDoc.layers.length;i++) {
			elem = findElement(n,curDoc.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
 
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (document.layers) {
				img = findElement(changeImages.arguments[i],0);
			}
			else {
				img = document.images[changeImages.arguments[i]];
			}
			if (img) {
				img.src = changeImages.arguments[i+1];
			}
		}
	}
}
 
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		indexmain_03_over = newImage("images/indexmain_03-over.gif");
		indexmain_05_over = newImage("images/indexmain_05-over.gif");
		indexmain_06_over = newImage("images/indexmain_06-over.gif");
		indexmain_07_over = newImage("images/indexmain_07-over.jpg");
		preloadFlag = true;
	}
}
 
// -->
</script>
<!-- End Preload Script -->
<!-- ImageReady Styles (indexmain.psd) -->
<style type="text/css">
body {
	padding-top:0;
	margin-top:0;
	background-color: #000000;
	background-image: url(images/blueline.jpg);
}
<!--
 
#Table_01 {
	position:absolute;
	left:0px;
	top:0px;
	width:800px;
	height:933px;
	padding: 0px;
	
}
#entirebody {
	position: relative;
	
}
 
#indexmaintop_ {
	position:absolute;
	left:0px;
	top:0px;
	width:800px;
	height:150px;
}
 
#indexmainleftstrip_ {
	position:absolute;
	left:0px;
	top:150px;
	width:25px;
	height:783px;
}
 
#indexmain-03_ {
	position:absolute;
	left:25px;
	top:150px;
	width:130px;
	height:27px;
}
 
#indexmainbody_ {
	position:absolute;
	left:155px;
	top:150px;
	width:645px;
	height:783px;
}
 
#indexmain-05_ {
	position:absolute;
	left:25px;
	top:177px;
	width:130px;
	height:27px;
}
 
#indexmain-06_ {
	position:absolute;
	left:25px;
	top:204px;
	width:130px;
	height:26px;
}
 
#indexmain-07_ {
	position:absolute;
	left:25px;
	top:230px;
	width:130px;
	height:30px;
}
 
#indexmainleft_ {
	position:absolute;
	left:25px;
	top:260px;
	width:130px;
	height:673px;
}
#welcome {
	position: absolute;
	left: 424px;
	top: 9px;
}
 
-->
</style>
<!-- End ImageReady Styles -->
</head>
<body onload="preloadImages();" style="background-color:#666666;">
<!-- ImageReady Slices (indexmain.psd) -->
 
<div id="entirebody" style="width: 800px; margin: 0px auto; ">
  <div id="Table_01">
	<div id="indexmaintop_">
		<a href="index.php">
			<img id="indexmaintop" src="images/indexmaintop.gif" width="800" height="150" border="0" alt="" /></a>
	</div>
	<div id="indexmainleftstrip_">
		<img id="indexmainleftstrip" src="images/indexmainleftstrip.gif" width="25" height="783" alt="" />
	</div>
	<div id="indexmain-03_">
		<a href="index.php"
			onmouseover="window.status='Return to Home Page'; changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_03', 'images/indexmain_03.gif'); return true;"
			onmousedown="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
			onmouseup="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;">
			<img name="indexmain_03" id="indexmain_03" src="images/indexmain_03.gif" width="130" height="27" border="0" alt="" /></a>
	</div>
	<div id="indexmainbody_">
		<img id="indexmainbody" src="images/indexmainbody.gif" width="645" height="783" alt="" />
	<div id="welcome"> Welcome <?php echo $row_Recordset1['username']; ?></div>
	</div>
	<div id="indexmain-05_">
		<a href="library.php"
			onmouseover="window.status='Search the Song Library'; changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_05', 'images/indexmain_05.gif'); return true;"
			onmousedown="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
			onmouseup="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;">
			<img name="indexmain_05" id="indexmain_05" src="images/indexmain_05.gif" width="130" height="27" border="0" alt="" /></a>
	</div>
	<div id="indexmain-06_">
		<a href="songwriters.php"
			onmouseover="window.status='Songwriters'; changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_06', 'images/indexmain_06.gif'); return true;"
			onmousedown="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
			onmouseup="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;">
			<img name="indexmain_06" id="indexmain_06" src="images/indexmain_06.gif" width="130" height="26" border="0" alt="" /></a>
	</div>
	<div id="indexmain-07_">
		<a href="songseekers.php"
			onmouseover="window.status='Seeking Music?'; changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_07', 'images/indexmain_07.jpg'); return true;"
			onmousedown="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
			onmouseup="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;">
			<img name="indexmain_07" id="indexmain_07" src="images/indexmain_07.jpg" width="130" height="30" border="0" alt="" /></a>
	</div>
	<div id="indexmainleft_">
		<img id="indexmainleft" src="images/indexmainleft.gif" width="130" height="673" alt="" />
	</div>
</div>
<!-- End ImageReady Slices --></div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

Open in new window

LVL 1
edvinsonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
hieloConnect With a Mentor Commented:
If I am understanding your code correctly, you are querying the database to extract the username on the posted code. Typically what you want to do is to have a "single" login page (say login.php). Once the user provides the correct username and password on the login page you set a $_SESSION variable that would indicate that the user already authenticated.

IMPORTANT: For SESSION variables to work, the browser must accept cookies and you must call session_start(); before you send any data to the browser. To be safe, you should start your php file wiht the statement: session_start();

So in your case you need to query the db once on login.php and if the user supplied the correct username and password then you can then say:
$_SESSION['username'] = $row_Recordset1['username'];

Once the $_SESSION['username'] is set, it will be visible on all other pages of your site without having to query the db every time.

Now, if the user goes to index2.php and if the user should be authenticated to gain access to the resources, then you first check if the session variable set during authentication exists. If not, send him/her to the login page. If so, let them through. This is what I did with your code below. Notice that I too started this page with session_start(); because even though $_SESSION['username'] should be set on login.php, I am going to use it on this page to welcome the user:
Welcome <?php echo $_SESSION['username'];?>!

So, to summarize, you need to update your login page so that it sets $_SESSION['username']
<?php
session_start();
 
if( !isset($_SESSION['username']) )
{
	header("Location: /loginfailure.php?accesscheck=/index2.php");
}
?>
<!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>
<title>PluASong.com and Findagreatsong.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- ImageReady Preload Script (indexmain.psd) -->
<script type="text/javascript">
<!--
 
userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
 
function findElement(n,ly) {
	if (browserVers < 4)		return document[n];
	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (!elem) {
		for (var i=0;i<curDoc.layers.length;i++) {
			elem = findElement(n,curDoc.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
 
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (document.layers) {
				img = findElement(changeImages.arguments[i],0);
			}
			else {
				img = document.images[changeImages.arguments[i]];
			}
			if (img) {
				img.src = changeImages.arguments[i+1];
			}
		}
	}
}
 
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		indexmain_03_over = newImage("images/indexmain_03-over.gif");
		indexmain_05_over = newImage("images/indexmain_05-over.gif");
		indexmain_06_over = newImage("images/indexmain_06-over.gif");
		indexmain_07_over = newImage("images/indexmain_07-over.jpg");
		preloadFlag = true;
	}
}
 
// -->
</script>
<!-- End Preload Script -->
<!-- ImageReady Styles (indexmain.psd) -->
<style type="text/css">
body {
	padding-top:0;
	margin-top:0;
	background-color: #000000;
	background-image: url(images/blueline.jpg);
}
<!--
 
#Table_01 {
	position:absolute;
	left:0px;
	top:0px;
	width:800px;
	height:933px;
	padding: 0px;
	
}
#entirebody {
	position: relative;
	
}
 
#indexmaintop_ {
	position:absolute;
	left:0px;
	top:0px;
	width:800px;
	height:150px;
}
 
#indexmainleftstrip_ {
	position:absolute;
	left:0px;
	top:150px;
	width:25px;
	height:783px;
}
 
#indexmain-03_ {
	position:absolute;
	left:25px;
	top:150px;
	width:130px;
	height:27px;
}
 
#indexmainbody_ {
	position:absolute;
	left:155px;
	top:150px;
	width:645px;
	height:783px;
}
 
#indexmain-05_ {
	position:absolute;
	left:25px;
	top:177px;
	width:130px;
	height:27px;
}
 
#indexmain-06_ {
	position:absolute;
	left:25px;
	top:204px;
	width:130px;
	height:26px;
}
 
#indexmain-07_ {
	position:absolute;
	left:25px;
	top:230px;
	width:130px;
	height:30px;
}
 
#indexmainleft_ {
	position:absolute;
	left:25px;
	top:260px;
	width:130px;
	height:673px;
}
#welcome {
	position: absolute;
	left: 424px;
	top: 9px;
}
 
-->
</style>
<!-- End ImageReady Styles -->
</head>
<body onload="preloadImages();" style="background-color:#666666;">
<!-- ImageReady Slices (indexmain.psd) -->
 
<div id="entirebody" style="width: 800px; margin: 0px auto; ">
  <div id="Table_01">
	<div id="indexmaintop_">
		<a href="index.php">
			<img id="indexmaintop" src="images/indexmaintop.gif" width="800" height="150" border="0" alt="" /></a>
	</div>
	<div id="indexmainleftstrip_">
		<img id="indexmainleftstrip" src="images/indexmainleftstrip.gif" width="25" height="783" alt="" />
	</div>
	<div id="indexmain-03_">
		<a href="index.php"
			onmouseover="window.status='Return to Home Page'; changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_03', 'images/indexmain_03.gif'); return true;"
			onmousedown="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
			onmouseup="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;">
			<img name="indexmain_03" id="indexmain_03" src="images/indexmain_03.gif" width="130" height="27" border="0" alt="" /></a>
	</div>
	<div id="indexmainbody_">
		<img id="indexmainbody" src="images/indexmainbody.gif" width="645" height="783" alt="" />
	<div id="welcome"> Welcome <?php echo $_SESSION['username']; ?></div>
	</div>
	<div id="indexmain-05_">
		<a href="library.php"
			onmouseover="window.status='Search the Song Library'; changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_05', 'images/indexmain_05.gif'); return true;"
			onmousedown="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
			onmouseup="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;">
			<img name="indexmain_05" id="indexmain_05" src="images/indexmain_05.gif" width="130" height="27" border="0" alt="" /></a>
	</div>
	<div id="indexmain-06_">
		<a href="songwriters.php"
			onmouseover="window.status='Songwriters'; changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_06', 'images/indexmain_06.gif'); return true;"
			onmousedown="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
			onmouseup="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;">
			<img name="indexmain_06" id="indexmain_06" src="images/indexmain_06.gif" width="130" height="26" border="0" alt="" /></a>
	</div>
	<div id="indexmain-07_">
		<a href="songseekers.php"
			onmouseover="window.status='Seeking Music?'; changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_07', 'images/indexmain_07.jpg'); return true;"
			onmousedown="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
			onmouseup="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;">
			<img name="indexmain_07" id="indexmain_07" src="images/indexmain_07.jpg" width="130" height="30" border="0" alt="" /></a>
	</div>
	<div id="indexmainleft_">
		<img id="indexmainleft" src="images/indexmainleft.gif" width="130" height="673" alt="" />
	</div>
</div>
<!-- End ImageReady Slices --></div>
</body>
</html>

Open in new window

0
 
Aamir SaeedCommented:
sorry i don't have time to read code but its very simple thing. you just start session on each page with session_start() where you want session and then after get logged in, store user name in session as

$_SESSION['name'] = 'aamir';

and then display it next to welcome as

Welcome, $_SESSION['name']
0
 
edvinsonAuthor Commented:
hmmm that didn't seem to work too good.
<?php require_once('Connections/PlugASong.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start($_SESSION['name'] = 'username');
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
 
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 
 
  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}
 
$MM_restrictGoTo = "loginfailure.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}
 
mysql_select_db($database_PlugASong, $PlugASong);
$query_Recordset1 = "SELECT * FROM users";
$Recordset1 = mysql_query($query_Recordset1, $PlugASong) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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>
<title>PlugASong.com and FindAGreatsong.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- ImageReady Preload Script (indexmain.psd) -->
<script type="text/javascript">
<!--
 
userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
 
function findElement(n,ly) {
	if (browserVers < 4)		return document[n];
	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (!elem) {
		for (var i=0;i<curDoc.layers.length;i++) {
			elem = findElement(n,curDoc.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
 
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (document.layers) {
				img = findElement(changeImages.arguments[i],0);
			}
			else {
				img = document.images[changeImages.arguments[i]];
			}
			if (img) {
				img.src = changeImages.arguments[i+1];
			}
		}
	}
}
 
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		indexmain_03_over = newImage("images/indexmain_03-over.gif");
		indexmain_05_over = newImage("images/indexmain_05-over.gif");
		indexmain_06_over = newImage("images/indexmain_06-over.gif");
		indexmain_07_over = newImage("images/indexmain_07-over.jpg");
		preloadFlag = true;
	}
}
 
// -->
</script>
<!-- End Preload Script -->
<!-- ImageReady Styles (indexmain.psd) -->
<style type="text/css">
body {
	padding-top:0;
	margin-top:0;
	background-color: #000000;
	background-image: url(images/blueline.jpg);
}
<!--
 
#Table_01 {
	position:absolute;
	left:0px;
	top:0px;
	width:800px;
	height:933px;
	padding: 0px;
	
}
#entirebody {
	position: relative;
	
}
 
#indexmaintop_ {
	position:absolute;
	left:0px;
	top:0px;
	width:800px;
	height:150px;
}
 
#indexmainleftstrip_ {
	position:absolute;
	left:0px;
	top:150px;
	width:25px;
	height:783px;
}
 
#indexmain-03_ {
	position:absolute;
	left:25px;
	top:150px;
	width:130px;
	height:27px;
}
 
#indexmainbody_ {
	position:absolute;
	left:155px;
	top:150px;
	width:645px;
	height:783px;
}
 
#indexmain-05_ {
	position:absolute;
	left:25px;
	top:177px;
	width:130px;
	height:27px;
}
 
#indexmain-06_ {
	position:absolute;
	left:25px;
	top:204px;
	width:130px;
	height:26px;
}
 
#indexmain-07_ {
	position:absolute;
	left:25px;
	top:230px;
	width:130px;
	height:30px;
}
 
#indexmainleft_ {
	position:absolute;
	left:25px;
	top:260px;
	width:130px;
	height:673px;
}
#welcome {
	position: absolute;
	left: 424px;
	top: 9px;
}
 
-->
</style>
<!-- End ImageReady Styles -->
</head>
<body onload="preloadImages();" style="background-color:#666666;">
<!-- ImageReady Slices (indexmain.psd) -->
 
<div id="entirebody" style="width: 800px; margin: 0px auto; ">
  <div id="Table_01">
	<div id="indexmaintop_">
		<a href="index.php">
			<img id="indexmaintop" src="images/indexmaintop.gif" width="800" height="150" border="0" alt="" /></a>
	</div>
	<div id="indexmainleftstrip_">
		<img id="indexmainleftstrip" src="images/indexmainleftstrip.gif" width="25" height="783" alt="" />
	</div>
	<div id="indexmain-03_">
		<a href="index.php"
			onmouseover="window.status='Return to Home Page'; changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_03', 'images/indexmain_03.gif'); return true;"
			onmousedown="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
			onmouseup="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;">
			<img name="indexmain_03" id="indexmain_03" src="images/indexmain_03.gif" width="130" height="27" border="0" alt="" /></a>
	</div>
	<div id="indexmainbody_">
		<img id="indexmainbody" src="images/indexmainbody.gif" width="645" height="783" alt="" />
	<div id="welcome"> Welcome $_SESSION['name']</div>
	</div>
	<div id="indexmain-05_">
		<a href="library.php"
			onmouseover="window.status='Search the Song Library'; changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_05', 'images/indexmain_05.gif'); return true;"
			onmousedown="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
			onmouseup="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;">
			<img name="indexmain_05" id="indexmain_05" src="images/indexmain_05.gif" width="130" height="27" border="0" alt="" /></a>
	</div>
	<div id="indexmain-06_">
		<a href="songwriters.php"
			onmouseover="window.status='Songwriters'; changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_06', 'images/indexmain_06.gif'); return true;"
			onmousedown="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
			onmouseup="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;">
			<img name="indexmain_06" id="indexmain_06" src="images/indexmain_06.gif" width="130" height="26" border="0" alt="" /></a>
	</div>
	<div id="indexmain-07_">
		<a href="songseekers.php"
			onmouseover="window.status='Seeking Music?'; changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_07', 'images/indexmain_07.jpg'); return true;"
			onmousedown="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
			onmouseup="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;">
			<img name="indexmain_07" id="indexmain_07" src="images/indexmain_07.jpg" width="130" height="30" border="0" alt="" /></a>
	</div>
	<div id="indexmainleft_">
		<img id="indexmainleft" src="images/indexmainleft.gif" width="130" height="673" alt="" />
	</div>
</div>
<!-- End ImageReady Slices --></div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

Open in new window

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Aamir SaeedCommented:
<?php require_once('Connections/PlugASong.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start($_SESSION['name'] = 'username');
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
 
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
  // For security, start by assuming the visitor is NOT authorized.
  $isValid = False;
 
  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
  // Therefore, we know that a user is NOT logged in if that Session variable is blank.
  if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
      $isValid = true;
    }
    // Or, you may restrict access to only certain users based on their username.
    if (in_array($UserGroup, $arrGroups)) {
      $isValid = true;
    }
    if (($strUsers == "") && true) {
      $isValid = true;
    }
  }
  return $isValid;
}
 
$MM_restrictGoTo = "loginfailure.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo);
  exit;
}
?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $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;
}
}
 
mysql_select_db($database_PlugASong, $PlugASong);
$query_Recordset1 = "SELECT * FROM users";
$Recordset1 = mysql_query($query_Recordset1, $PlugASong) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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>
<title>PlugASong.com and FindAGreatsong.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- ImageReady Preload Script (indexmain.psd) -->
<script type="text/javascript">
<!--
 
userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
function newImage(arg) {
      if (document.images) {
            rslt = new Image();
            rslt.src = arg;
            return rslt;
      }
}
 
function findElement(n,ly) {
      if (browserVers < 4)            return document[n];
      var curDoc = ly ? ly.document : document;
      var elem = curDoc[n];
      if (!elem) {
            for (var i=0;i<curDoc.layers.length;i++) {
                  elem = findElement(n,curDoc.layers[i]);
                  if (elem) return elem;
            }
      }
      return elem;
}
 
function changeImages() {
      if (document.images && (preloadFlag == true)) {
            var img;
            for (var i=0; i<changeImages.arguments.length; i+=2) {
                  img = null;
                  if (document.layers) {
                        img = findElement(changeImages.arguments[i],0);
                  }
                  else {
                        img = document.images[changeImages.arguments[i]];
                  }
                  if (img) {
                        img.src = changeImages.arguments[i+1];
                  }
            }
      }
}
 
var preloadFlag = false;
function preloadImages() {
      if (document.images) {
            indexmain_03_over = newImage("images/indexmain_03-over.gif");
            indexmain_05_over = newImage("images/indexmain_05-over.gif");
            indexmain_06_over = newImage("images/indexmain_06-over.gif");
            indexmain_07_over = newImage("images/indexmain_07-over.jpg");
            preloadFlag = true;
      }
}
 
// -->
</script>
<!-- End Preload Script -->
<!-- ImageReady Styles (indexmain.psd) -->
<style type="text/css">
body {
      padding-top:0;
      margin-top:0;
      background-color: #000000;
      background-image: url(images/blueline.jpg);
}
<!--
 
#Table_01 {
      position:absolute;
      left:0px;
      top:0px;
      width:800px;
      height:933px;
      padding: 0px;
      
}
#entirebody {
      position: relative;
      
}
 
#indexmaintop_ {
      position:absolute;
      left:0px;
      top:0px;
      width:800px;
      height:150px;
}
 
#indexmainleftstrip_ {
      position:absolute;
      left:0px;
      top:150px;
      width:25px;
      height:783px;
}
 
#indexmain-03_ {
      position:absolute;
      left:25px;
      top:150px;
      width:130px;
      height:27px;
}
 
#indexmainbody_ {
      position:absolute;
      left:155px;
      top:150px;
      width:645px;
      height:783px;
}
 
#indexmain-05_ {
      position:absolute;
      left:25px;
      top:177px;
      width:130px;
      height:27px;
}
 
#indexmain-06_ {
      position:absolute;
      left:25px;
      top:204px;
      width:130px;
      height:26px;
}
 
#indexmain-07_ {
      position:absolute;
      left:25px;
      top:230px;
      width:130px;
      height:30px;
}
 
#indexmainleft_ {
      position:absolute;
      left:25px;
      top:260px;
      width:130px;
      height:673px;
}
#welcome {
      position: absolute;
      left: 424px;
      top: 9px;
}
 
-->
</style>
<!-- End ImageReady Styles -->
</head>
<body onload="preloadImages();" style="background-color:#666666;">
<!-- ImageReady Slices (indexmain.psd) -->
 
<div id="entirebody" style="width: 800px; margin: 0px auto; ">
  <div id="Table_01">
      <div id="indexmaintop_">
            <a href="index.php">
                  <img id="indexmaintop" src="images/indexmaintop.gif" width="800" height="150" border="0" alt="" /></a>
      </div>
      <div id="indexmainleftstrip_">
            <img id="indexmainleftstrip" src="images/indexmainleftstrip.gif" width="25" height="783" alt="" />
      </div>
      <div id="indexmain-03_">
            <a href="index.php"
                  onmouseover="window.status='Return to Home Page'; changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
                  onmouseout="window.status=''; changeImages('indexmain_03', 'images/indexmain_03.gif'); return true;"
                  onmousedown="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
                  onmouseup="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;">
                  <img name="indexmain_03" id="indexmain_03" src="images/indexmain_03.gif" width="130" height="27" border="0" alt="" /></a>
      </div>
      <div id="indexmainbody_">
            <img id="indexmainbody" src="images/indexmainbody.gif" width="645" height="783" alt="" />
      <div id="welcome"> Welcome <?php echo $_SESSION['name']; ?></div>
      </div>
      <div id="indexmain-05_">
            <a href="library.php"
                  onmouseover="window.status='Search the Song Library'; changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
                  onmouseout="window.status=''; changeImages('indexmain_05', 'images/indexmain_05.gif'); return true;"
                  onmousedown="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
                  onmouseup="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;">
                  <img name="indexmain_05" id="indexmain_05" src="images/indexmain_05.gif" width="130" height="27" border="0" alt="" /></a>
      </div>
      <div id="indexmain-06_">
            <a href="songwriters.php"
                  onmouseover="window.status='Songwriters'; changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
                  onmouseout="window.status=''; changeImages('indexmain_06', 'images/indexmain_06.gif'); return true;"
                  onmousedown="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
                  onmouseup="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;">
                  <img name="indexmain_06" id="indexmain_06" src="images/indexmain_06.gif" width="130" height="26" border="0" alt="" /></a>
      </div>
      <div id="indexmain-07_">
            <a href="songseekers.php"
                  onmouseover="window.status='Seeking Music?'; changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
                  onmouseout="window.status=''; changeImages('indexmain_07', 'images/indexmain_07.jpg'); return true;"
                  onmousedown="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
                  onmouseup="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;">
                  <img name="indexmain_07" id="indexmain_07" src="images/indexmain_07.jpg" width="130" height="30" border="0" alt="" /></a>
      </div>
      <div id="indexmainleft_">
            <img id="indexmainleft" src="images/indexmainleft.gif" width="130" height="673" alt="" />
      </div>
</div>
<!-- End ImageReady Slices --></div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
0
 
Aamir SaeedCommented:
as this is PHP code so you need to embed it into

<?php
   // here is our code
?>
0
 
Aamir SaeedCommented:
just for example



<?php session_start();
	$_SESSION['var_name'] = 'name';
	echo $_SESSION['var_name'];
?>

Open in new window

0
 
edvinsonAuthor Commented:
Thanks...but..

I replaced my code with yours and uploaded it, but it still doesn't display anything next to Welcome

www.plugasong.com/login.php
0
 
edvinsonAuthor Commented:
For being so simple this is sure turning out to be anything but...???
<?php require_once('Connections/PlugASong.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start($_SESSION['name'] = 'username');
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
 
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 
 
  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}
 
$MM_restrictGoTo = "loginfailure.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?><?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}
 
mysql_select_db($database_PlugASong, $PlugASong);
$query_Recordset1 = "SELECT * FROM users";
$Recordset1 = mysql_query($query_Recordset1, $PlugASong) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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>
<title>PlugASong.com and FindAGreatsong.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- ImageReady Preload Script (indexmain.psd) -->
<script type="text/javascript">
<!--
 
userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
function newImage(arg) {
      if (document.images) {
            rslt = new Image();
            rslt.src = arg;
            return rslt;
      }
}
 
function findElement(n,ly) {
      if (browserVers < 4)            return document[n];
      var curDoc = ly ? ly.document : document;
      var elem = curDoc[n];
      if (!elem) {
            for (var i=0;i<curDoc.layers.length;i++) {
                  elem = findElement(n,curDoc.layers[i]);
                  if (elem) return elem;
            }
      }
      return elem;
}
 
function changeImages() {
      if (document.images && (preloadFlag == true)) {
            var img;
            for (var i=0; i<changeImages.arguments.length; i+=2) {
                  img = null;
                  if (document.layers) {
                        img = findElement(changeImages.arguments[i],0);
                  }
                  else {
                        img = document.images[changeImages.arguments[i]];
                  }
                  if (img) {
                        img.src = changeImages.arguments[i+1];
                  }
            }
      }
}
 
var preloadFlag = false;
function preloadImages() {
      if (document.images) {
            indexmain_03_over = newImage("images/indexmain_03-over.gif");
            indexmain_05_over = newImage("images/indexmain_05-over.gif");
            indexmain_06_over = newImage("images/indexmain_06-over.gif");
            indexmain_07_over = newImage("images/indexmain_07-over.jpg");
            preloadFlag = true;
      }
}
 
// -->
</script>
<!-- End Preload Script -->
<!-- ImageReady Styles (indexmain.psd) -->
<style type="text/css">
body {
      padding-top:0;
      margin-top:0;
      background-color: #000000;
      background-image: url(images/blueline.jpg);
}
<!--
 
#Table_01 {
      position:absolute;
      left:0px;
      top:0px;
      width:800px;
      height:933px;
      padding: 0px;
      
}
#entirebody {
      position: relative;
      
}
 
#indexmaintop_ {
      position:absolute;
      left:0px;
      top:0px;
      width:800px;
      height:150px;
}
 
#indexmainleftstrip_ {
      position:absolute;
      left:0px;
      top:150px;
      width:25px;
      height:783px;
}
 
#indexmain-03_ {
      position:absolute;
      left:25px;
      top:150px;
      width:130px;
      height:27px;
}
 
#indexmainbody_ {
      position:absolute;
      left:155px;
      top:150px;
      width:645px;
      height:783px;
}
 
#indexmain-05_ {
      position:absolute;
      left:25px;
      top:177px;
      width:130px;
      height:27px;
}
 
#indexmain-06_ {
      position:absolute;
      left:25px;
      top:204px;
      width:130px;
      height:26px;
}
 
#indexmain-07_ {
      position:absolute;
      left:25px;
      top:230px;
      width:130px;
      height:30px;
}
 
#indexmainleft_ {
      position:absolute;
      left:25px;
      top:260px;
      width:130px;
      height:673px;
}
#welcome {
      position: absolute;
      left: 424px;
      top: 9px;
}
 
-->
</style>
<!-- End ImageReady Styles -->
</head>
<body onload="preloadImages();" style="background-color:#666666;">
<!-- ImageReady Slices (indexmain.psd) -->
 
<div id="entirebody" style="width: 800px; margin: 0px auto; ">
  <div id="Table_01">
      <div id="indexmaintop_">
            <a href="index.php">
                  <img id="indexmaintop" src="images/indexmaintop.gif" width="800" height="150" border="0" alt="" /></a>
      </div>
      <div id="indexmainleftstrip_">
            <img id="indexmainleftstrip" src="images/indexmainleftstrip.gif" width="25" height="783" alt="" />
      </div>
      <div id="indexmain-03_">
            <a href="index.php"
                  onmouseover="window.status='Return to Home Page'; changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
                  onmouseout="window.status=''; changeImages('indexmain_03', 'images/indexmain_03.gif'); return true;"
                  onmousedown="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
                  onmouseup="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;">
                  <img name="indexmain_03" id="indexmain_03" src="images/indexmain_03.gif" width="130" height="27" border="0" alt="" /></a>
      </div>
      <div id="indexmainbody_">
            <img id="indexmainbody" src="images/indexmainbody.gif" width="645" height="783" alt="" />
      <div id="welcome"> Welcome <?php echo $_SESSION['name']; ?></div>
      </div>
      <div id="indexmain-05_">
            <a href="library.php"
                  onmouseover="window.status='Search the Song Library'; changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
                  onmouseout="window.status=''; changeImages('indexmain_05', 'images/indexmain_05.gif'); return true;"
                  onmousedown="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
                  onmouseup="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;">
                  <img name="indexmain_05" id="indexmain_05" src="images/indexmain_05.gif" width="130" height="27" border="0" alt="" /></a>
      </div>
      <div id="indexmain-06_">
            <a href="songwriters.php"
                  onmouseover="window.status='Songwriters'; changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
                  onmouseout="window.status=''; changeImages('indexmain_06', 'images/indexmain_06.gif'); return true;"
                  onmousedown="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
                  onmouseup="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;">
                  <img name="indexmain_06" id="indexmain_06" src="images/indexmain_06.gif" width="130" height="26" border="0" alt="" /></a>
      </div>
      <div id="indexmain-07_">
            <a href="songseekers.php"
                  onmouseover="window.status='Seeking Music?'; changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
                  onmouseout="window.status=''; changeImages('indexmain_07', 'images/indexmain_07.jpg'); return true;"
                  onmousedown="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
                  onmouseup="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;">
                  <img name="indexmain_07" id="indexmain_07" src="images/indexmain_07.jpg" width="130" height="30" border="0" alt="" /></a>
      </div>
      <div id="indexmainleft_">
            <img id="indexmainleft" src="images/indexmainleft.gif" width="130" height="673" alt="" />
      </div>
</div>
<!-- End ImageReady Slices --></div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

Open in new window

0
 
edvinsonAuthor Commented:
Anybody have an answer please?
0
 
edvinsonAuthor Commented:
Thanks hielo

I took your code and pasted it into the file index3.php and uploaded it.

I changed the login now to go to that page once correct username pw entered.

Where on the login page do I put your suggested code? I tried putting it at the top with a session start but of course that didn't work or make any sense.

Which line should $_SESSION['username'] be placed please?
LOGIN.PHP
 
<?php require_once('Connections/PlugASong.php'); ?>
<?php
	
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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 = "";
  $MM_redirectLoginSuccess = "index3.php";
  $MM_redirectLoginFailed = "loginfailure.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db($database_PlugASong, $PlugASong);
  
  $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $PlugASong) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      
 
    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!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>
<title>PlugASong.com and FindAGreatsong.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- ImageReady Preload Script (indexmain.psd) -->
<script type="text/javascript">
<!--
 
userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
 
function findElement(n,ly) {
	if (browserVers < 4)		return document[n];
	var curDoc = ly ? ly.document : document;
	var elem = curDoc[n];
	if (!elem) {
		for (var i=0;i<curDoc.layers.length;i++) {
			elem = findElement(n,curDoc.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
 
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			if (document.layers) {
				img = findElement(changeImages.arguments[i],0);
			}
			else {
				img = document.images[changeImages.arguments[i]];
			}
			if (img) {
				img.src = changeImages.arguments[i+1];
			}
		}
	}
}
 
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		indexmain_03_over = newImage("images/indexmain_03-over.gif");
		indexmain_05_over = newImage("images/indexmain_05-over.gif");
		indexmain_06_over = newImage("images/indexmain_06-over.gif");
		indexmain_07_over = newImage("images/indexmain_07-over.jpg");
		preloadFlag = true;
	}
}
 
// -->
</script>
<!-- End Preload Script -->
<!-- ImageReady Styles (indexmain.psd) -->
<style type="text/css">
body {
	padding-top:0;
	margin-top:0;
	background-color: #000000;
	background-image: url(images/blueline.jpg);
}
<!--
 
#Table_01 {
	position:absolute;
	left:0px;
	top:0px;
	width:800px;
	height:933px;
	padding: 0px;
	
}
#entirebody {
	position: relative;
	
}
 
#indexmaintop_ {
	position:absolute;
	left:0px;
	top:0px;
	width:800px;
	height:150px;
}
 
#indexmainleftstrip_ {
	position:absolute;
	left:0px;
	top:150px;
	width:25px;
	height:783px;
}
 
#indexmain-03_ {
	position:absolute;
	left:25px;
	top:150px;
	width:130px;
	height:27px;
}
 
#indexmainbody_ {
	position:absolute;
	left:155px;
	top:150px;
	width:645px;
	height:783px;
}
 
#indexmain-05_ {
	position:absolute;
	left:25px;
	top:177px;
	width:130px;
	height:27px;
}
 
#indexmain-06_ {
	position:absolute;
	left:25px;
	top:204px;
	width:130px;
	height:26px;
}
 
#indexmain-07_ {
	position:absolute;
	left:25px;
	top:230px;
	width:130px;
	height:30px;
}
 
#indexmainleft_ {
	position:absolute;
	left:25px;
	top:260px;
	width:130px;
	height:673px;
}
.style1 {	font-family: Geneva, Arial, Helvetica, sans-serif;
	font-size: 12px;
}
.style2 {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 12px;
	color: #FFFFFF;
}
.style3 {
	font-family: Georgia, "Times New Roman", Times, serif;
	color: #FFFFFF;
}
#form1 {	z-index: 10;
	position: absolute;
	top: 275px;
	left: 25px;
}
.style4 {color: #FFFFFF}
 
-->
</style>
<!-- End ImageReady Styles -->
</head>
<body onload="preloadImages();" style="background-color:#666666;">
<!-- ImageReady Slices (indexmain.psd) -->
<div id="entirebody" style="width: 800px; margin: 0px auto; ">
  <div id="Table_01">
  <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
  <label> <span class="style1"><span class="style3">Login </span><span class="style4">&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
  <input name="username" type="text" id="username" />
  <br />
  </label>
  <p> <span class="style2">Password</span>
      <input name="password" type="text" id="password" />
      <br />
      <br />
      <input type="submit" name="Submit" value="Submit" />
  </p>
</form>
 
	<div id="indexmaintop_">
		<a href="index.php">
			<img id="indexmaintop" src="images/indexmaintop.gif" width="800" height="150" border="0" alt="" /></a>
	</div>
	<div id="indexmainleftstrip_">
		<img id="indexmainleftstrip" src="images/indexmainleftstrip.gif" width="25" height="783" alt="" />
	</div>
	<div id="indexmain-03_">
		<a href="index.php"
			onmouseover="window.status='Return to Home Page'; changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_03', 'images/indexmain_03.gif'); return true;"
			onmousedown="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;"
			onmouseup="changeImages('indexmain_03', 'images/indexmain_03-over.gif'); return true;">
			<img name="indexmain_03" id="indexmain_03" src="images/indexmain_03.gif" width="130" height="27" border="0" alt="" /></a>
	</div>
	<div id="indexmainbody_">
		<img id="indexmainbody" src="images/indexmainbody.gif" width="645" height="783" alt="" />
	</div>
	<div id="indexmain-05_">
		<a href="library.php"
			onmouseover="window.status='Search the Song Library'; changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_05', 'images/indexmain_05.gif'); return true;"
			onmousedown="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;"
			onmouseup="changeImages('indexmain_05', 'images/indexmain_05-over.gif'); return true;">
			<img name="indexmain_05" id="indexmain_05" src="images/indexmain_05.gif" width="130" height="27" border="0" alt="" /></a>
	</div>
	<div id="indexmain-06_">
		<a href="songwriters.php"
			onmouseover="window.status='Songwriters'; changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_06', 'images/indexmain_06.gif'); return true;"
			onmousedown="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;"
			onmouseup="changeImages('indexmain_06', 'images/indexmain_06-over.gif'); return true;">
			<img name="indexmain_06" id="indexmain_06" src="images/indexmain_06.gif" width="130" height="26" border="0" alt="" /></a>
	</div>
	<div id="indexmain-07_">
		<a href="songseekers.php"
			onmouseover="window.status='Seeking Music?'; changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
			onmouseout="window.status=''; changeImages('indexmain_07', 'images/indexmain_07.jpg'); return true;"
			onmousedown="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;"
			onmouseup="changeImages('indexmain_07', 'images/indexmain_07-over.jpg'); return true;">
			<img name="indexmain_07" id="indexmain_07" src="images/indexmain_07.jpg" width="130" height="30" border="0" alt="" /></a>
	</div>
	<div id="indexmainleft_">
		<img id="indexmainleft" src="images/indexmainleft.gif" width="130" height="673" alt="" />
	</div>
</div>
<!-- End ImageReady Slices --></div>
</body>
</html>

Open in new window

0
 
edvinsonAuthor Commented:
Would have helped to have line numbers and page filename references in the answer. Thanks for responding though. i do appreciate your help.
0
 
hieloCommented:
>>Would have helped to have line numbers and page references in the answer
Line number references are typically used when only a fragment of the code is referenced. I gave you a complete and updated file. When this is the case, typically posters save the entire file as a new test file and test it independently of the original "problematic file".

>>Would have helped to have filename references in the answer
Before you "complain" you should pay attention at what you provide and at what you got. The file you provided is not a login page. If you read carefully, I clearly told you that your login query and the set up of the SESSION variable needs to be addressed at login.php. I could point you to a line within login.php because you did not supply the code to login.php when I posted my detailed response. Quite frankly your grading is disappointing.

On another note, if you are not clear on a point, or have questions, ask before closing the problem. And if you ask, give us enough time to respond before closing the problem. Not all of us are on the same timezone. Based on your last post, it seems to me you are still confused since your login.php, as posted, is not accurate.
0
 
edvinsonAuthor Commented:
My apologies indeed. I guess I didn't realize you needed more info for one and that giving a lower grade was such a sensitive issue.

I will always give the best grade allowed from now on.

You Masters easily speak at levels way above the rest of us seeking your advice and I think in dealing with us you may assume we know more than we do.

I apologize.

I had to take your most recent instruction and re-poised a question and did get a short concise answer that worked.

If interested you can see it maybe...??  I figured I just wasn't being clear enough, evident in your assessment here.

I did give you all the points as the person before you basically let me know he didn't really have time for me.

Again, please accept my apologies, I thought I was helping you to help others like me in the future.

I stand corrected.

e!
0
All Courses

From novice to tech pro — start learning today.