40 users online (1 members and 39 guests)  


  Results 1 to 12 of 12

Related

  1. Replies: 1
  2. One Click Login    Forum: Javascript Forum
    Replies: 1
  3. cant login to myspace    Forum: Myspace Forum
    Replies: 6
  4. login popup    Forum: Javascript Forum
    Replies: 0
  1. #1
    davidgriff's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Posts
    19

    Switch login with logout?

    I know this is probably a stupid newbie question but that's what I am with PHP. I know how to do this in ASP but I don't know how to translate it to PHP. What I want to do is change the "Login" image to a "Logout" image when a user is logged in. Simple I know, but I just don't know enough PHP to do it. Thanks much.

    David

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Switch login with logout?

    do you have code that you need edited, or are you going from scratch?(please post some code)

    even if it is ASP code, that will give some help on what the parameters and variables you use

  3. #3
    davidgriff's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Posts
    19

    Re: Switch login with logout?

    Here is the code I'm trying to replicate in PHP. I know its very simple and I really should take the time to learn PHP properly but this is the only thing Dreamweaver isn't able to do for me. I know I'll have to change the link for the logout image to reflect a PHP action instead of the ASP included but that should be relatively easy.

    Thanks for all your help.

    Code:
    <% If Session("MM_Username") <> "" Then %>
    <a href="<%= MM_Logout %>" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('logout','','../imgs/Logout_button_ov.jpg',1)"><img src="../imgs/Logout_button.jpg" name="logout" width="145" height="31" border="0" id="logout" /></a>
    <% Else %>
    <a href="../login.asp" target="_top" onClick="MM_nbGroup('down','group1','login','',1)" onMouseOver="MM_nbGroup('over','login','../imgs/login_button_ov.jpg','',1)" onMouseOut="MM_nbGroup('out')"><img src="../imgs/login_button.jpg" alt="" name="login" width="145" height="31" border="0" onload=""></a>
    <% End If %>

  4. #4
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Switch login with logout?

    Code:
    <?php
    session_start ();
    if (isset ($_SESSION['MM_Username'])){
    \\I am not sure how you are storing MM_Logout, but i guessed a variable
    echo "<a href=$MM_Logout onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('logout','','../imgs/Logout_button_ov.jpg',1)"><img src=\"../imgs/Logout_button.jpg\" name=\"logout\" width=\"145\" height=\"31\" border=\"0\" id=\"logout\" /></a>";
    }else{
    echo "<a href=\"../login.asp\" target=\"_top\" onClick=\"MM_nbGroup('down','group1','login','',1)\" onMouseOver="MM_nbGroup('over','login','../imgs/login_button_ov.jpg','',1)\" onMouseOut=\"MM_nbGroup('out')\"><img src=\"../imgs/login_button.jpg\" alt=\"\" name=\"login\" width=\"145\" height=\"31\" border=\"0\" onload=\"\"></a>";
    }
    ?>

  5. #5
    davidgriff's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Posts
    19

    Re: Switch login with logout?

    Thanks for the heads up on the code. Unfortunately when inserting the code given I recieve a parse error on the first echo line in the code you gave me. Any idea what might be causing this? Also, any good books you can recommend for a PHP beginner using Dreamweaver MX 2004? Thanks again.


    Code:
    <?php require_once('Connections/ghost.php'); ?><?php
    // *** Validate request to login to this site.
    session_start();
    
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      session_unregister('MM_Username');
      session_unregister('MM_UserGroup');
    	
      $logoutGoTo = "login.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
      }
    }
    
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($accesscheck)) {
      $GLOBALS['PrevUrl'] = $accesscheck;
      session_register('PrevUrl');
    }
    
    if (isset($_POST['usr'])) {
      $loginUsername=$_POST['usr'];
      $password=$_POST['pwd'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "index.php";
      $MM_redirectLoginFailed = "loginerr.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_ghost, $ghost);
      
      $LoginRS__query=sprintf("SELECT Usr, Pwd FROM customers WHERE Usr='%s' AND Pwd='%s'",
        get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
       
      $LoginRS = mysql_query($LoginRS__query, $ghost) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        
        //declare two session variables and assign them
        $GLOBALS['MM_Username'] = $loginUsername;
        $GLOBALS['MM_UserGroup'] = $loginStrGroup;	      
    
        //register the session variables
        session_register("MM_Username");
        session_register("MM_UserGroup");
    
        if (isset($_SESSION['PrevUrl']) && false) {
          $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>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Ghost Light Photography Login</title>
    <link href="global.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="../rollover.js" type="text/JavaScript"></script>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    </head>
    
    <body onload="MM_preloadImages('../imgs/Port_button_ov.jpg','../imgs/Stock_button_ov.jpg','../imgs/login_button_ov.jpg','../imgs/contact_button_ov.jpg','imgs/Headshts_button_ov.jpg')">
    
    <table width="726" border="0" align="center">
      <tr>
        <td><img src="imgs/ghostbanner.jpg" width="726" height="85"></td>
      </tr>
    </table>
    <table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="145" height="100"><a href="portfolio.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('port','','imgs/Port_button_ov.jpg',1)"><img src="imgs/Port_button.jpg" name="port" width="145" height="31" border="0" id="port" /></a></td>
        <td width="475" height="500" rowspan="5"><form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="login" id="login">
          <table width="251" border="0" align="center">
            <tr>
              <td width="86">Username</td>
              <td width="155"><input name="usr" type="text" id="usr" /></td>
            </tr>
            <tr>
              <td>Password</td>
              <td><input name="pwd" type="text" id="pwd" /></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><input type="submit" name="Submit" value="Submit" /></td>
            </tr>
          </table>
          <p>&nbsp;      </p>
        </form>
        </td>
        <td width="105" height="500" rowspan="5">&nbsp;</td>
      </tr>
      <tr>
        <td height="100"><a href="headshots.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('head','','imgs/Headshts_button_ov.jpg',1)"><img src="imgs/Headshts_button.jpg" name="head" width="145" height="31" border="0" id="head" /></a></td>
      </tr>
      <tr>
        <td height="100"><a href="stock.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('stock','','imgs/Stock_button_ov.jpg',1)"><img src="imgs/Stock_button.jpg" name="stock" width="145" height="31" border="0" id="stock" /></a></td>
      </tr>
      <tr>
        <td height="100">
    	<?php
    session_start ();
    if (isset ($_SESSION['MM_Username'])){
    echo "<a href=$logoutAction onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('logout','','imgs/Logout_button_ov.jpg',1)"><img src=\"imgs/Logout_button.jpg\" name=\"logout\" width=\"145\" height=\"31\" border=\"0\" id=\"logout\" /></a>";
    }else{
    echo "<a href=\"login.php\" target=\"_top\" onClick=\"MM_nbGroup('down','group1','login','',1)\" onMouseOver="MM_nbGroup('over','login','imgs/login_button_ov.jpg','',1)\" onMouseOut=\"MM_nbGroup('out')\"><img src=\"imgs/login_button.jpg\" alt=\"\" name=\"login\" width=\"145\" height=\"31\" border=\"0\" onload=\"\"></a>";
    }
    ?>
    </td>
      </tr>
      <tr>
        <td height="100"><a href="contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','imgs/contact_button_ov.jpg',1)"><img src="imgs/contact_button.jpg" name="contact" width="145" height="31" border="0" id="contact" /></a></td>
      </tr>
    </table>
    
    </body>
    </html>

  6. #6
    davidgriff's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Posts
    19

    Re: Switch login with logout?

    Ok, must learn to do some trouble shooting before posting.

    I've got it most working by replacing all the double quotes + / within the echo string with single quotes. The only problem seems to be my rollover now. It doesn't work. Perhaps I need to keep some double quotes in there to keep it working? Here is my new code.

    Code:
    	<?php
    if (isset ($_SESSION['MM_Username'])){
    echo "<a href='$logoutAction' onmouseout='MM_swapImgRestore()' onmouseover='MM_swapImage('logoutbutton','','imgs/Logout_button_ov.jpg',1)'><img src='imgs/Logout_button.jpg' name='logoutbutton' width='145' height='31' border='0' id='logoutbutton' /></a>";
    }else{
    echo "<a href='login.php' onmouseout='MM_swapImgRestore()' onmouseover='MM_swapImage('loginbutton','','imgs/login_button_ov.jpg',1)'><img src='imgs/login_button.jpg' name='loginbutton' width='145' height='31' border='0' id='loginbutton' /></a>";
    }
    ?>

  7. #7
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Switch login with logout?

    found it, i just missed a " here:
    Code:
    <?php require_once('Connections/ghost.php'); ?><?php
    // *** Validate request to login to this site.
    session_start();
    
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      session_unregister('MM_Username');
      session_unregister('MM_UserGroup');
    	
      $logoutGoTo = "login.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
      }
    }
    
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($accesscheck)) {
      $GLOBALS['PrevUrl'] = $accesscheck;
      session_register('PrevUrl');
    }
    
    if (isset($_POST['usr'])) {
      $loginUsername=$_POST['usr'];
      $password=$_POST['pwd'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "index.php";
      $MM_redirectLoginFailed = "loginerr.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_ghost, $ghost);
      
      $LoginRS__query=sprintf("SELECT Usr, Pwd FROM customers WHERE Usr='%s' AND Pwd='%s'",
        get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
       
      $LoginRS = mysql_query($LoginRS__query, $ghost) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        
        //declare two session variables and assign them
        $GLOBALS['MM_Username'] = $loginUsername;
        $GLOBALS['MM_UserGroup'] = $loginStrGroup;	      
    
        //register the session variables
        session_register("MM_Username");
        session_register("MM_UserGroup");
    
        if (isset($_SESSION['PrevUrl']) && false) {
          $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>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Ghost Light Photography Login</title>
    <link href="global.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="../rollover.js" type="text/JavaScript"></script>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    </head>
    
    <body onload="MM_preloadImages('../imgs/Port_button_ov.jpg','../imgs/Stock_button_ov.jpg','../imgs/login_button_ov.jpg','../imgs/contact_button_ov.jpg','imgs/Headshts_button_ov.jpg')">
    
    <table width="726" border="0" align="center">
      <tr>
        <td><img src="imgs/ghostbanner.jpg" width="726" height="85"></td>
      </tr>
    </table>
    <table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="145" height="100"><a href="portfolio.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('port','','imgs/Port_button_ov.jpg',1)"><img src="imgs/Port_button.jpg" name="port" width="145" height="31" border="0" id="port" /></a></td>
        <td width="475" height="500" rowspan="5"><form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="login" id="login">
          <table width="251" border="0" align="center">
            <tr>
              <td width="86">Username</td>
              <td width="155"><input name="usr" type="text" id="usr" /></td>
            </tr>
            <tr>
              <td>Password</td>
              <td><input name="pwd" type="text" id="pwd" /></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><input type="submit" name="Submit" value="Submit" /></td>
            </tr>
          </table>
          <p>&nbsp;      </p>
        </form>
        </td>
        <td width="105" height="500" rowspan="5">&nbsp;</td>
      </tr>
      <tr>
        <td height="100"><a href="headshots.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('head','','imgs/Headshts_button_ov.jpg',1)"><img src="imgs/Headshts_button.jpg" name="head" width="145" height="31" border="0" id="head" /></a></td>
      </tr>
      <tr>
        <td height="100"><a href="stock.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('stock','','imgs/Stock_button_ov.jpg',1)"><img src="imgs/Stock_button.jpg" name="stock" width="145" height="31" border="0" id="stock" /></a></td>
      </tr>
      <tr>
        <td height="100">
    	<?php
    session_start ();
    if (isset ($_SESSION['MM_Username'])){
    echo "<a href=$logoutAction onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('logout','','imgs/Logout_button_ov.jpg',1)\"><img src=\"imgs/Logout_button.jpg\" name=\"logout\" width=\"145\" height=\"31\" border=\"0\" id=\"logout\" /></a>";
    }else{
    echo "<a href=\"login.php\" target=\"_top\" onClick=\"MM_nbGroup('down','group1','login','',1)\" onMouseOver="MM_nbGroup('over','login','imgs/login_button_ov.jpg','',1)\" onMouseOut=\"MM_nbGroup('out')\"><img src=\"imgs/login_button.jpg\" alt=\"\" name=\"login\" width=\"145\" height=\"31\" border=\"0\" onload=\"\"></a>";
    }
    ?>
    </td>
      </tr>
      <tr>
        <td height="100"><a href="contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','imgs/contact_button_ov.jpg',1)"><img src="imgs/contact_button.jpg" name="contact" width="145" height="31" border="0" id="contact" /></a></td>
      </tr>
    </table>
    
    </body>
    </html>

  8. #8
    davidgriff's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Posts
    19

    Re: Switch login with logout?

    Missed one in the second echo line as well.....but now that I know what to look for that is fixed. I'm learning and I thank you again for you patience. Any idea about the rollover though? Still broken on just the login/logout image.

  9. #9
    davidgriff's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Posts
    19

    Re: Switch login with logout?

    Ok, here is the really strange thing.

    The rollover for the Login image does not work on the login page. Once logged in the rollover for the logout image works just fine. On the page that a client is redirected to after login, both rollovers work fine. Same for the gallery page. However when loading the gallery page, it always says login not matter if one is logged in or not. I'm about to go running back to ASP pretty soon here.....

  10. #10
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Switch login with logout?

    do you have a page where i can see it?

    in the mean time try this:
    Code:
    <?php require_once('Connections/ghost.php'); ?><?php
    // *** Validate request to login to this site.
    session_start();
    
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    }
    
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      session_unregister('MM_Username');
      session_unregister('MM_UserGroup');
    	
      $logoutGoTo = "login.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
      }
    }
    
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($accesscheck)) {
      $GLOBALS['PrevUrl'] = $accesscheck;
      session_register('PrevUrl');
    }
    
    if (isset($_POST['usr'])) {
      $loginUsername=$_POST['usr'];
      $password=$_POST['pwd'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "index.php";
      $MM_redirectLoginFailed = "loginerr.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_ghost, $ghost);
      
      $LoginRS__query=sprintf("SELECT Usr, Pwd FROM customers WHERE Usr='%s' AND Pwd='%s'",
        get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
       
      $LoginRS = mysql_query($LoginRS__query, $ghost) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        
        //declare two session variables and assign them
        $GLOBALS['MM_Username'] = $loginUsername;
        $GLOBALS['MM_UserGroup'] = $loginStrGroup;	      
    
        //register the session variables
        session_register("MM_Username");
        session_register("MM_UserGroup");
    
        if (isset($_SESSION['PrevUrl']) && false) {
          $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>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Ghost Light Photography Login</title>
    <link href="global.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="../rollover.js" type="text/JavaScript"></script>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    </head>
    
    <body onload="MM_preloadImages('../imgs/Port_button_ov.jpg','../imgs/Stock_button_ov.jpg','../imgs/login_button_ov.jpg','../imgs/contact_button_ov.jpg','imgs/Headshts_button_ov.jpg')">
    
    <table width="726" border="0" align="center">
      <tr>
        <td><img src="imgs/ghostbanner.jpg" width="726" height="85"></td>
      </tr>
    </table>
    <table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="145" height="100"><a href="portfolio.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('port','','imgs/Port_button_ov.jpg',1)"><img src="imgs/Port_button.jpg" name="port" width="145" height="31" border="0" id="port" /></a></td>
        <td width="475" height="500" rowspan="5"><form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="login" id="login">
          <table width="251" border="0" align="center">
            <tr>
              <td width="86">Username</td>
              <td width="155"><input name="usr" type="text" id="usr" /></td>
            </tr>
            <tr>
              <td>Password</td>
              <td><input name="pwd" type="text" id="pwd" /></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><input type="submit" name="Submit" value="Submit" /></td>
            </tr>
          </table>
          <p>&nbsp;      </p>
        </form>
        </td>
        <td width="105" height="500" rowspan="5">&nbsp;</td>
      </tr>
      <tr>
        <td height="100"><a href="headshots.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('head','','imgs/Headshts_button_ov.jpg',1)"><img src="imgs/Headshts_button.jpg" name="head" width="145" height="31" border="0" id="head" /></a></td>
      </tr>
      <tr>
        <td height="100"><a href="stock.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('stock','','imgs/Stock_button_ov.jpg',1)"><img src="imgs/Stock_button.jpg" name="stock" width="145" height="31" border="0" id="stock" /></a></td>
      </tr>
      <tr>
        <td height="100">
    	<?php
    echo $_SESSION['MM_Username'];
    if (isset ($_SESSION['MM_Username'])){
    echo "<a href=$logoutAction onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('logout','','imgs/Logout_button_ov.jpg',1)\"><img src=\"imgs/Logout_button.jpg\" name=\"logout\" width=\"145\" height=\"31\" border=\"0\" id=\"logout\" /></a>";
    }else{
    echo "<a href=\"login.php\" target=\"_top\" onClick=\"MM_nbGroup('down','group1','login','',1)\" onMouseOver="MM_nbGroup('over','login','imgs/login_button_ov.jpg','',1)\" onMouseOut=\"MM_nbGroup('out')\"><img src=\"imgs/login_button.jpg\" alt=\"\" name=\"login\" width=\"145\" height=\"31\" border=\"0\" onload=\"\"></a>";
    }
    ?>
    </td>
      </tr>
      <tr>
        <td height="100"><a href="contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','imgs/contact_button_ov.jpg',1)"><img src="imgs/contact_button.jpg" name="contact" width="145" height="31" border="0" id="contact" /></a></td>
      </tr>
    </table>
    
    </body>
    </html>
    i removed "session_start()" because it has already started, so it should still return it, but if you have problems, try it with adding it.

    i also had it echo the Session, that will show why it is not working correctly, tell me the results, or the pages when you get it up.

  11. #11
    davidgriff's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2005
    Posts
    19

    Re: Switch login with logout?

    All,

    Thank for the try on this. Still having the rollover problem. I should have a server up and running by tomorrow evening if all goes well and I'll have you take a look then. Thanks again.

    David

  12. #12
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Switch login with logout?

    tommorow i am going to get MY computer back, so i should beable to test it my self tommorow evening.

    Cheers,
    -ALL



Tags for this Thread