PHP實(shí)現(xiàn)會員注冊系統(tǒng)
分享一個基于PHP的非常簡單基礎(chǔ)的注冊系統(tǒng),為了減輕難度沒有使用Cookie和Session,數(shù)據(jù)庫大家按照自己需求更改,有問題歡迎聯(lián)系我。
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <a href="join_us.html" > 注冊 </a> <h2>分開一下</h2> <a href="login.html" > 登錄 </a> </body> </html>
join_us.html
注冊頁面,發(fā)一個表單給add_member.php,使用post。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>歡迎加入我們</h1>
<form action="add_member.php" method="post" name="register_form">
<table>
<tr>
<td>
用戶名:
</td>
<td>
<input name="member_name" type="text">
</td>
</tr>
<tr>
<td>
輸入密碼:
</td>
<td>
<input name="member_password" type="password">
</td>
</tr>
<tr>
<td><input type="submit" value="確定" >
</td>
</table>
</form>
</body>
</html>
add_member.php
稍微用了一下js,也可以用header(),僅測試使用,項(xiàng)目不要傻乎乎的給root權(quán)限。
<?php
$account = $_POST["member_name"];
$password = $_POST["member_password"];
//獲取字段信息
$link = mysqli_connect("127.0.0.1", "root", "") or die("連接失敗");
//連接數(shù)據(jù)庫
mysqli_select_db($link, "jack");
//連接數(shù)據(jù)表
$sql = "SELECT * FROM info WHERE Name='$account'";
$result = mysqli_query($link, $sql);
//檢索數(shù)據(jù)庫同名賬戶
if (mysqli_num_rows($result) != 0) {
mysqli_free_result($result);
mysqli_close($link);
//釋放空間
echo "<script>alert('該用戶名已被使用');history.go(-1);</script>";
//返回
}
//同名賬戶返回注冊頁
else {
$sql = "INSERT INTO info(Name,Password) VALUES( '$account','$password' )";
mysqli_query($link, $sql);
//寫入
mysqli_free_result($result);
mysqli_close($link);
//釋放空間
echo"注冊成功";
}
//非同名寫入數(shù)據(jù)庫
?>
login.html
登錄頁面,發(fā)表單給check_password.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h2>
歡迎登錄
</h2>
<form action="check_password.php" method="post" name="register_form">
<table>
<tr>
<td>
用戶名:
</td>
<td>
<input name="member_name" type="text">
</td>
</tr>
<tr>
<td>
輸入密碼:
</td>
<td>
<input name="member_password" type="password">
</td>
</tr>
<tr>
<td><input type="submit" value="確定" >
</td>
</table>
</form>
</body>
</html>
check_password.php
驗(yàn)證密碼
<?php
$account = $_POST["member_name"];
$password = $_POST["member_password"];
//獲取字段信息
$link = mysqli_connect("127.0.0.1", "root", "") or die("連接失敗");
//連接數(shù)據(jù)庫
mysqli_select_db($link, "jack");
//連接數(shù)據(jù)表
$sql = "SELECT * FROM info WHERE Name='$account'AND Password='$password'";
$result=mysqli_query($link,$sql);
if (mysqli_num_rows($result) == 0) {
mysqli_free_result($result);
mysqli_close($link);
//釋放空間
echo "<script>alert('賬戶或密碼錯誤');history.go(-1);</script>";
//返回
}
else{
mysqli_free_result($result);
mysqli_close($link);
//釋放空間
echo "登錄成功";
//建議在此處setcookie();
}
?>
都是很基礎(chǔ)的東西,大家多多交流。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
PHP實(shí)現(xiàn)使用優(yōu)酷土豆視頻地址獲取swf播放器分享地址
這篇文章主要介紹了PHP實(shí)現(xiàn)使用優(yōu)酷土豆視頻地址獲取swf播放器分享地址,即分析優(yōu)酷土豆的視頻頁面地址,從而獲得對應(yīng)的swf播放器分享地址,需要的朋友可以參考下2014-06-06
ThinkPHP表單數(shù)據(jù)智能寫入create方法實(shí)例分析
這篇文章主要介紹了ThinkPHP表單數(shù)據(jù)智能寫入create方法,以實(shí)例形式較為詳細(xì)的分析了ThinkPHP中create只能寫入的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-09-09
centos 7系統(tǒng)下安裝laravel運(yùn)行環(huán)境的步驟詳解
Laravel框架對于開發(fā)網(wǎng)頁應(yīng)用來說是一個絕好的的工具,最近正好又在學(xué)習(xí)linux系統(tǒng),所以下面這篇文章主要給大家介紹了在centos 7系統(tǒng)下安裝laravel運(yùn)行環(huán)境的步驟,需要的朋友可以參考借鑒,下面跟著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2017-08-08
php中單個數(shù)據(jù)庫字段多列顯示(單字段分頁、橫向輸出)
這篇文章主要介紹了php中單個數(shù)據(jù)庫字段多列顯示、分行分列顯示技巧,也可稱為單字段分頁、橫向輸出,需要的朋友可以參考下2014-07-07

