"Logout" soll nicht angezeigt werden

Radhad

Erfahrenes Mitglied
Hallo zusammen,

ich habe ein eher kleines Problem. Und zwar wird bei mir im nicht eingeloggten Zustand der "Logout"-Link angezeigt.

PHP:
<?php session_start ();
if(isset($_GET["action"]))
{
  $section=$_GET["action"];
}
else
{
  $section="news";
}
?>
<html>

<head>
<title>DLM Jordan-MidlandF1 Team</title>
</head>

<body>

<table width="750" border="1" cellspacing="0" cellpadding="0">
  <tr><td colspan="2">BANNER</td></tr>
  <tr>
    <td width="150" valign="top">
      <table width="100%" border="1" cellspacing="0" cellpadding="0">
        <tr>
          <td>
            <?php
            if (!isset ($_SESSION["user_id"]))
            { ?>
            <form action="login.php" method="post">
              Name: <input type="text" name="name" size="20"><br>
              Kennwort: <input type="password" name="pwd" size="20"><br>
              <input type="submit" value="Login"><a href="logout.php">Logout</a>
            </form> <a href="index.php?section=register">Registrieren</a>
            <?php }
            else
            { ?>
            <a href="logout.php">Logout</a>
            <?php } ?>
          </td>
        </tr>
      </table>
    </td>
    <td align="center" valign="top"><br>
    <?php
    switch($section)
    {
      case 'news':
      {
        include("news.inc");
      }
      break;
      default:
      {
        include("news.inc");
      }
      break;
    }
    ?>
    </td>
  </tr>
</table>
</body>
</html>

Allerdings verstehe ich nicht, weshalb das so ist.
Kann man den Login-Button auch durch Text ersetzen?


Gruß Radhad
 
Du hast den Logout-Link im If und im else Zweig drinnen ;)
dh. Er zeigt es immer an.

Und dein 2. Problem:
HTML:
<!-- deinem form musst du noch einen namen geben: -->
<form action="login.php" method="post" name="login">

<!-- statt dem Button nun folgenden Link: -->
<a href="JavaScript:document.login.submit()">Login</a>
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück