Hello to all. I do not know what kind of attack. Wrote a fragment of this type allows you to change the shape depending on the presence of the user. I reviewed a bunch of examples on the network, and everywhere this composition works for everyone. I have the same problem, it works either input or output, depending on the condition. Although everything else works, and displaying a separate button on "logout.php" session closes without problems, but the form remains fixed. Where am I wrong?

<form action="login.php" method="post"><center> <?php if($_SESSION['status']!="login") { ?> <label>Логин:</label><br> <input type="text" name="login" placeholder="Login"></input><br> <label>Пароль:</label><br> <input type="password" name="password" placeholder="Password"></input><br> <input type="submit" name="submit" value="Enter"><br> <button formaction="registration.php">Регистрация</button></center> <?php } else if ($_SESSION['status']=="login") { ?> <label>Добро пожаловать,<? echo " ".$_SESSION['name']." ".$_SESSION['surname']."!" ?> </label> <button formaction=logout.php>Выход</button> <?php } ?> </form> 

  • First, you can delete if ($_SESSION['status']=="login") . http://www.w3schools.com/tags/att_input_formaction.asp Not all browsers work formaction !. - E_p
  • Also, the center does not always close, but only when there is no session - E_p
  • I have no problems with formaction . There is no change of the exit form on the login form when exiting the session. Yes exactly. By center only paid attention. - Kirill
  • then the contents of logout.php in the studio! - E_p

1 answer 1

Solved the problem myself. Check the condition with ! = True and ! = False . Now everything works fine.

  • one
    $ var! = true and $ var! = false is better to replace with a simpler expression! $ var. It is not customary to compare with boolean values. - cheops
  • By the way as an option! I tried it, everything works in the same way. - Kirill