Easy login script without database

后端 未结 10 1953
说谎
说谎 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 21:01

    It's not an ideal solution but here's a quick and dirty example that shows how you could store login info in the PHP code:

    'password1',
                    'user2'=>'password2'
                    );
    
    if(isset($_GET['logout'])) {
        $_SESSION['username'] = '';
        header('Location:  ' . $_SERVER['PHP_SELF']);
    }
    
    if(isset($_POST['username'])) {
        if($userinfo[$_POST['username']] == $_POST['password']) {
            $_SESSION['username'] = $_POST['username'];
        }else {
            //Invalid Login
        }
    }
    ?>
    
    
        
            Login
        
        
            
                

    You are logged in as

    Logout

    Username:
    Password:

提交回复
热议问题