mysql php最簡單的登陸註冊

2021-10-01 11:36:51 字數 2950 閱讀 8278

目錄結構:

使用者登陸<

/title>

form,h2

<

/style>

<

/head>

/h2>

login.php:

<?php 

header

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

$conn

=mysql_connect

("localhost:3306"

,"使用者名稱"

,"密碼");

if($conn);

$select

=mysql_select_db

("資料庫名"

,$conn);

if($select);

$abc

=mysql_query

("set names utf8");

if($abc);

$username

=$_post

['username'];

if($username

)else

echo

'username失敗'.'

';$password

=$_post

['password'];

if($username

)else

echo

'password失敗'.'

';$sql

="select username,password from tb_atest where username = '$username

' and password = '$password'";

$result

=mysql_query

($sql

,$conn);

$row

=mysql_fetch_object

($result);

dowhile

($row

=mysql_fetch_object

($result))

;//這裡必須寫mysql_fetch_object

mysql_free_result

($result);

mysql_close

($conn);

echo

'登陸完成'

;

register.html:

<

!doctype html>

"en"

>

"utf-8"

>

"viewport"

content=

"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"

>

"x-ua-compatible" content=

"ie=edge"

>

使用者註冊<

/title>

form,h2

<

/style>

<

/head>

/h2>

register.php

<?php 

header

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

$conn

=mysql_connect

("localhost:3306"

,"使用者名稱"

,"密碼");

mysql_select_db

("資料庫名"

,$conn);

mysql_query

("set names utf8");

$username

=$_post

['username'];

$password

=$_post

['password'];

$confirmpw

=$_post

['confirmpw'];

if($password

!=$confirmpw);

$sql

="insert into tb_atest values(null,$username

,$password)";

mysql_query

($sql

,$conn);

$result

=mysql_query

("select username from tb_atest where username = '$username'",

$conn);

if($result

)

mysql版本盡量在5.0左右

最簡單的Shiro免密登陸(springboot)

思路比較簡單,實現也簡單,要的就是簡單!實際專案中可以此基礎上封裝 重寫usernamepasswordtoken 中 getcredentials 方法。所以新增了類nopwdtoken 在userrealm類中的dogetauthenticationinfo authenticationtoke...

Cookie,簡單的登陸

cookie 客戶端的會話技術 資料庫儲存在瀏覽器上 用cookie做乙個簡單的登陸系統 1.html內容 views.py部分內容 def login request data 獲取儲存在cookie中的使用者名稱,密碼 username request.cookies.get username ...

簡單的登陸認證程式

編寫登陸認證程式 user info tom jerry f open black user user f.readlines lock user for i in user i i.strip print 鎖定使用者 lock user f.close count 0 count1 0 while...