php實現登入註冊介面

2022-07-26 20:03:12 字數 3669 閱讀 8010

首先你要搭建乙個自己的資料庫

我用wamp64創了乙個people的資料庫

這裡就講下我實現的功能**:

<?php

/***

彈框*/

function_alert($_info)

/*** _location():

彈出乙個對話方塊並且轉跳到另乙個介面

* @accesspublic

* @paramstring$_info 

對話方塊上顯示的資訊

* @paramstring$_url  

轉跳的頁面位址

* @returnvoid

*/function_location($_info,$_url)else

}/**

* _connect():

連線資料庫

* @accesspublic

* @returnvoid

*/function_connect()

}/**

* _select_db():

選擇資料庫

* @accesspublic

* @returnvoid

*/function_select_db()

}/**

* _set_names():

設定字元編碼

* @accesspublic

* @returnvoid

*/function_set_names()

}/**

* _query():

執行sql

語句* @accesspublic

* @paramstring$_sql sql

操作語句

* @returnstring

返回結果集

*/function_query($_sql)

return$result;

}/**

* _fetch_array():

根據sql

語句遍歷資料庫。返回乙個陣列,鍵名是資料庫的表單結構名

* @accesspublic

* @paramstring$_sql sql

操作語句

* @returnarray|null

*/function_fetch_array($_sql)

/*** _num_rows():

返回資料庫中查詢條件的資料個數

* @accesspublic

* @paramstring$_sql sql

操作語句

* @returnint

返回資料個數

*/function_num_rows($_sql)

/*** _affected_rows():

返回資料庫裡被影響到的資料條數

* @accesspublic

* @returnint

返回影響到的記錄數

*/function_affected_rows()

/*** _is_repeat():

判斷資料在資料庫裡是否已經存在

* @accesspublic

* @paramstring$_sql sql

操作語句

* @paramstring$_info 

彈窗上顯示的文字

* @returnvoid

*/function_is_repeat($_sql,$_info)

}/**

* _close():

關閉資料庫

* @accesspublic

*/function_close()

}?>

<?php

$_conn=mysqli_connect('localhost','root','');

if(!$_conn) 

mysqli_select_db($_conn,'people')or die('

找不到資料庫:

'.mysqli_error($_conn).mysqli_errno($_conn));

mysqli_query($_conn,"set names utf8");

// var_dump($_conn);

include"sql.func.php";

?>

<?php

include"./connect.php";

//接收資料

if(isset($_post['register']))

if(isset($_post['userid']) && isset($_post['password']))'";

$result= _fetch_array($_sql);

if(!empty($result[0]))else

}else

_close();

exit;

}?>

<?php

include"./connect.php";

if(isset($_post['index'])) _location("","index.html");

//接收資料

if(isset($_post['userid']) && isset($_post['password']))','')";

$_result= _query($_sql);

_location("

註冊成功!

","index.html");

_close();

exit;

}else

?>

doctypehtml>

註冊title>

#register

#form

label

body

style>

head>

使用者名稱:li>

密   

碼:li>

label>

註冊">

返回">

li>

ul>

form>

div>

div>

body>

html>

doctypehtml>

doctypehtml>

登入title>

#login

#form

label

body

style>

head>

使用者登入

legend>

使用者名稱:label>

li>

密碼:label>

li>

label>

登入">

註冊">

個人總結:個人也是一知半解,還是需要去吃透這些**,理解php響應的內涵要點,本人菜鳥,不喜勿噴

PHP登入介面與註冊介面連線

主要核心 驗證註冊介面 將註冊的資料 使用者名稱和密碼插入資料庫 test中的users表中 link mysqli connect localhost root root test 鏈結資料庫 header content type text html charset utf 8 if link ...

php註冊和登入介面的實現案例 推薦

當初我覺得乙個 上註冊和登入這兩個功能很神奇,後來自己研究一下發現其實道理很簡單,接下來看一下怎麼實現的吧。我在我的電腦上建了幾個檔案 login.html 登入頁面 register.html 註冊頁面 success.html 登入成功跳轉頁面 return.html 註冊成功頁面 login....

註冊登入介面作業

網頁原始碼 index session start header content type text html charset utf 8 register header content type text html charset utf 8 check include headerfiles.p...