php session 登入退出驗證

2022-02-14 04:18:21 字數 1250 閱讀 8596

login.html 負責收集使用者填寫的登入資訊

使用者登入

登入處理login.php 負責處理使用者登入與退出動作

<?php

header("content-type:text/html;charset=utf-8");

if(!isset($_post['submit']))

$username = htmlspecialchars($_post['username']);

$password = md5($_post['password']);

//包含資料庫連線檔案

include('conn.php');

//檢測使用者名稱及密碼是否正確

$check_query = mysql_query("select uid from user where username='$username' and password='$password' limit 1");

if($result = mysql_fetch_array($check_query)) else

退出處理處理使用者退出的**跟處理登入的**都在 login.php 裡。 session_start();

//登出登入

if($_get['action'] == "logout")

?>

my.php

<?php

header("content-type:text/html;charset=utf-8");

session_start();

//檢測是否登入,若沒登入則轉向登入介面

if(!isset($_session['userid']))

//包含資料庫連線檔案

include('conn.php');

$userid = $_session['userid'];

$username = $_session['username'];

$user_query = mysql_query("select * from user where uid=$userid limit 1");

$row = mysql_fetch_array($user_query);

echo '使用者資訊:

';echo '使用者id:'.$userid.'

';echo '使用者名稱:'.$username.'

';echo '登出 登入

';?>

PHP session登入案例

思路 使用session儲存使用者的登入狀態,在需要登入的頁面判斷session來判斷是否跳轉到登入頁面 session原理不是很了解,就是開始乙個session之後伺服器會產生乙個檔案儲存資訊,並且客戶端會有乙個cookie來記錄sessionid來保持和伺服器的通訊 啟動 session ses...

html退出登入 退出登入 0152

使用者只需要向 spring security 專案中傳送 logout 退出請求即可。1 退出實現 實現退出非常簡單,只要在頁面中新增 log 退出登入為了實現更好的效果,通常新增退出的配置。預設的退出 url 為 logout,退出成功後跳轉到 login?logout 如果不希望使用預設值,可...

退出登入狀態

colspan 2 style text align center href request.getcontextpath add.jsp 註冊新使用者a td tr colspan 2 style text align center href request.getcontextpath logo...