Easy login script without database

后端 未结 10 1941
说谎
说谎 2020-12-04 20:17

How do I create an easy login script that does not require a database. I would like it to be safe.

Alright, what about this script, i just made it by my knowledge in

10条回答
  •  无人及你
    2020-12-04 20:51

    Try this:

    '5d41402abc4b2a76b9719d911017c592', //Hello...
            );
    
            if(isset($_GET['logout'])) {
                $_SESSION['username'] = '';
                header('Location:  ' . $_SERVER['PHP_SELF']);
            }
    
            if(isset($_POST['username'])) {
                if($userinfo[$_POST['username']] == md5($_POST['password'])) {
                    $_SESSION['username'] = $_POST['username'];
                }else {
                    header("location:403.html"); //replace with 403
                }
            }
    ?>
    
        
        
            
                
                Logged In
            
    
            
                

    You're logged in.

    LOG OUT Log In

    Login needed

    System Login
    Username:
    Password:
     

    You will need a logout, something like this (logout.php):

    
    
    // Below is not needed, unless header above is missing. In that case, put logged out text here.
    
    
        
            
            Untitled Document
        
        
            
        
    
    

提交回复
热议问题