Jump to content
Fórum Script Brasil
  • 0

Mostrar formulário de login ou usuário logado


Paxtel

Question

Gostaria de mostrar o formulário de login apenas se ninguém estiver logado, caso tenha alguém logado mostrar o nome dessa pessoa, com o código abaixo aparece o formulário independente de ter alguém logado...

<?php

if (!isset($_SESSION['usuarioID']) OR !isset($_SESSION['usuarioNome'])) {

echo '<form method=post" action="validacao.php">

<label>Usuário</label>

<input type="text" name="usuario" maxlength="50" />

<label>Senha</label>

<input type="password" name="senha" maxlength="50" />

<a href="admin.php"><input type="submit" value="Entrar" /></a>

</form>';

} else {

echo "Olá, " . $_SESSION['usuarioNome];}

?>

já consegui fazer funcionar, obrigado pela ajuda =)

Edited by Paxtel
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Tenta assim;

<?php

if (empty($_SESSION['usuarioID']) && empty($_SESSION['usuarioNome'])) {

echo '<form method=post" action="validacao.php">

<label>Usuário</label>

<input type="text" name="usuario" maxlength="50" />

<label>Senha</label>

<input type="password" name="senha" maxlength="50" />

<a href="admin.php"><input type="submit" value="Entrar" /></a>

</form>';

} else {

echo "Olá, " . $_SESSION['usuarioNome];}

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...