creating login page with PHP

前端 未结 1 742
终归单人心
终归单人心 2021-01-24 07:45

I am trying to create website with login form with some PHP code, were user will try to login with username and password and page will then show \"welcome....\". AT the moment w

相关标签:
1条回答
  • 2021-01-24 08:30

    First off...dont store the password in the session. Thats just asking for trouble.

    session_register("password");
    

    Secondly....session_register() is a deprecated function and shouldn't be used anymore.

    Instead do...

         $_SESSION['username'] = $myusername;
    

    Third....

    header("location:page1.html");
    

    Should be a PHP file if you want sessions to work across pages..

    header("location:page1.php");
    

    Then in that PHP page do...

    session_start();
    if(!isset($_SESSION['username'])){
       header("location:index.php");
    } else {
         // Display stuff to logged in user
    }
    
    0 讨论(0)
提交回复
热议问题