Jump to content

[SOLVED] GRRR 2 hrs and still can't find my error


Btown2

Recommended Posts

maybe you guys can tell me why this is failing.

 

<?php
session_start();

if(isset($_SESSION['username']) && isset($_SESSION['password']))
{
	$username = $_SESSION['username'];
	$password = md5($_SESSION['password']);

	include dbconnect.php;

	$query = "select * from users where username = '$username'";

	$result = mysql_query($query) or die("Error with session login name/password.");

	$user = mysql_fetch_row($result);

	if($password == $user[1])
		$_SESSION['loggedin'] = "true";

	else
		$_SESSION['loggedin'] = "false";

	include 'closedb.php';
}
else
{
	$_SESSION['loggedin'] = "false";
}
?>
<!DOCTYPE HTML PUBLIC "-//ISU HTML 4.01 Transitional//EN">
<html>
<head>
<title>Brayton Thompson</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="myCSS.css" rel="stylesheet" type="text/css">
</head> 
<body>
<div id="navigation"> 

<h2>Site Map</h2>
<ul>
<?php
	include 'dbconnect.php'; 

	$query = "select * from site_map";

	$result = mysql_query($query) or die("Error getting links from MySQL");

	$num_rows = mysql_num_rows($result);

	$i = 0;

	for(;$i < $num_rows; $i++)
	{
		$row = mysql_fetch_row($result);
		$anchor = $row[0];
		$url = $row[1];
		echo ("<li><a href='$url'>$anchor</a></li>");
	}

	include 'closedb.php';
?>
</ul>

<br>

<h2>Helpful Links</h2>
<ul>
<?php
	include 'dbconnect.php';

	$query = "select * from helpful_links";

	$result = mysql_query($query) or die("Error getting links from MySQL");

	$num_rows = mysql_num_rows($result);

	$i = 0;

	for(;$i < $num_rows; $i++)
	{
		$row = mysql_fetch_row($result);
		$anchor = $row[0];
		$url = $row[1];
		echo("<li><a href='$url'>$anchor</a></li>");
	}

	include 'closedb.php';
?>
</u1>

</div> 

<div id="centerDoc"> 

<?php
if($_SESSION['loggedin'] == "true")
{
	echo ("<h1>Welcome $_SESSION['username']!</h1>");
} 
else
{
	echo ("<h1>Welcome! (please log in)</h1>");
}

echo ("$_SESSION['loggedin']");
?>
<p> 

Hello! Welcome to my site. I am Brayton Thompson, a Junior at Indiana State University majoring in Computer Science.
</p> 

</div> 
</body>
</html>

 

Thanks in advance for the help.

change this:

<?php
if($_SESSION['loggedin'] == "true")
{
	echo ("<h1>Welcome $_SESSION['username']!</h1>");
} 
else
{
	echo ("<h1>Welcome! (please log in)</h1>");
}

echo ("$_SESSION['loggedin']");
?>

 

to this:

 

<?php
if($_SESSION['loggedin'] == "true")
{
	echo ("<h1>Welcome ".$_SESSION['username']."!</h1>");
} 
else
{
	echo ("<h1>Welcome! (please log in)</h1>");
}

echo ($_SESSION['loggedin']);
?>

 

when using echo, you need to seperate functions of php with text... basically by following this format:

echo "blah text".function['blah']."more text";

 

try that and get back to us  :)

change this:

<?php
if($_SESSION['loggedin'] == "true")
{
	echo ("<h1>Welcome $_SESSION['username']!</h1>");
} 
else
{
	echo ("<h1>Welcome! (please log in)</h1>");
}

echo ("$_SESSION['loggedin']");
?>

 

to this:

 

<?php
if($_SESSION['loggedin'] == "true")
{
	echo ("<h1>Welcome ".$_SESSION['username']."!</h1>");
} 
else
{
	echo ("<h1>Welcome! (please log in)</h1>");
}

echo ($_SESSION['loggedin']);
?>

 

when using echo, you need to seperate functions of php with text... basically by following this format:

echo "blah text".function['blah']."more text";

 

try that and get back to us  :)

 

 

Wow, that was it. Thank you so much.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.