php基於cookie的登入表單(記錄最後登入時間)

來源:互聯網
上載者:User
本文介紹下,基於cookie實現的一個php登入表單,且可以記錄下最後的登入時間,有需要的朋友參考下。

一個基於cookie原理實現的登入表單。

代碼:

<html>  <head>  <title>使用者登入表單</title>  </head>  <body>  <form name="forml" method="POST" action="CookieBasedPasswordLogin.php">    <table>      <tr>       <td colspan="2" >         <p align="center"><b>請輸入使用者名稱與密碼</b></p>       </td>     </tr>   <tr>>     <td>       <p align="right">Customer ID</p>     </td>     <td>       <input type="text" name="username">     </td>   </tr>   <tr>     <td>       <p align="right">Password</p>     </td>     <td>       <input type="password" name="password">     </td>   </tr>   <tr>     <td colspan="2">       <center>         <input type="submit" name="Submit" value="Login">       </center>     </td>    </tr>   </table>  </form>  </body>  </html>  <!-- CookieBasedPasswordLogin.php<?php//檢測使用者登入//基於cookie實現的使用者登入檢測程式//edit by www.jbxue.com    $now = getdate();    $storetime= $now["weekday"] . " " . $now["month"] ." " . $now["year"] ;    $storetime.=" Time : ";    if ($now["hours"] < 10) {      $storetime.= "0" . $now["hours"];    } else {      $storetime.= $now["hours"];    }      $storetime.= ":";    if ($now["minutes"]<10) {      $storetime.= "0" . $now["minutes"];    } else {      $storetime.= $now["minutes"];    }        $storetime.= ": ";    if ($now["seconds"] <10) {      $storetime.= "0" . $now["seconds"];    } else {      $storetime.= $now["seconds"];    }    if (isset($data)) {       $counter=++$data[l];        setcookie("data[0]",$storetime,time() + (60*60*24));        setcookie("data[l]", $counter,time() + (60*60*24)); setcookie("data[2]",$username,time() + (60*60*24));        echo "<b><center>Hi " . $data[2] . " ! !</center></b><br>n";        echo "<b><center>Last Login Time :" .$data[0] . "</center></b><br>n";        echo "<b><center>Current Date :" .$storetime. "</center></b><br>n";        echo "<b><center>Page View Count :" . $data[l]. "</center></b><br>n";        echo "<b><center>成功登入!</center></b>";        echo ("<b><contor>您可以在24小時內,無需再次登入,即可訪問本站的內容。</center></b>");   } else {    if (isset($username) && isset($password)) {     if ($password=="superpass") {          $counter=0;          setcookie("data[0]",$storetime,time() + (60*60*24));          setcookie("data[l]",$counter,time() + (60*60*24));          setcookie("data[2]",$username,time() + (60*60*24));          $url="Location: cookieimp.php";          header($url);     }else{          echo "<hl><center>密碼無效!</center></hl>";     }    }  }  ?>  -->

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.