Creating a very simple 1 username/password login in php

后端 未结 5 1082
甜味超标
甜味超标 2020-12-04 22:52

I want to make a single login for just 1 user without storing in a database but I can\'t seem to get this to work.

My code: login.php


&         


        
5条回答
  •  遥遥无期
    2020-12-04 23:18

    Your code could look more like:

    
    
    
    
      
      Login
    
    
      
    " id="username" name="username" />

    Now, when the page is redirected based on the header('LOCATION:wherever.php), put session_start() at the top of the page and test to make sure $_SESSION['login'] === true. Remember that == would be true if $_SESSION['login'] == 1 as well. Of course, this is a bad idea for security reasons, but my example may teach you a different way of using PHP.

提交回复
热议问题