simple and basic login


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. if($_GET['acao']=="logar"){
  3. $senha = $_POST['pwd'];
  4. if($senha=="trielo"){
  5. $_SESSION['userName'] = "UserNameXXX";
  6. $_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
  7. header("Location: /home.php");
  8. exit;
  9. } else {
  10. echo "Senha incorreta!";
  11. }
  12.  
  13. }
  14. ?>
  15.  
  16. //other pages
  17.  
  18. <?php
  19. if((!$_SESSION['userName'])||($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT']))){
  20. header("Location: /");
  21. }
  22. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.