I have racked my brain and I can not figure this out. I am trying to make a header file that I can use as an include called header.php. The header file will display graphic and a logon form is the user is not logged in. If they are logged in it will just display the graphic and state the user is logged on. When I try to run the following code I get the error:
Notice: Undefined index: logged in c:\inetpub\wwwroot\vlogs\header.php on line 15
When I refresh the page I no longer get this error because I have the following code:
----CODE----
if(!$SESSION['logged']){
$SESSION['logged'] = "";}
else{}
----/CODE----
so I thought I would cheat a little and use this instead:
----CODE----
if(!$SESSION['logged']){
$SESSION['logged'] = "";}
echo '<META HTTP-EQUIV="refresh" CONTENT="3; URL=http://24.208.244.240/vlogs/header.php">';
else{}
----/CODE----
This just caused a continual loop of refreshes. I am out of ideas. Here is my code so far.
----CODE----
<?
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<HTML>
<BODY>
<CENTER>
<TABLE>
<TR>
<TD>
<IMG SRC="splashheader.gif">
</TD>
<?
if(!$SESSION['logged']){
$SESSION['logged'] = "";}
else{}
if($_SESSION['logged'] == ""){
echo"
<TD ALIGN=\"right\">
<form method=\"POST\" action=\"login.php\">
Username: <input type=\"text\" name=\"username\" size=\"20\"><BR>
Password: <input type=\"password\" name=\"password\" size=\"20\"><BR>
<input type=\"submit\" value=\"Submit\" name=\"login\">
</form>
</TD>
</TR>
</TABLE>
</CENTER>
<BR><BR>
</BODY>";
}
else {
echo $_SESSION['user'];
echo " Logged In
</TABLE>
</CENTER>
<BR><BR>
</BODY>";}
?>
----/CODE----
Is there an easier way to get this done? I am probably way overdoing my code but it is all I can think of to try to get this done.