1.登錄代碼
<html>
<head>
<meta charset="utf-8">
<title>網(wǎng)絡(luò)部人員管理系統(tǒng)</title>
<link rel="stylesheet" type="text/css" href="css/index.css" />
</head>
<body>
<h1>歡迎進入怜瞒,請登錄</h1>
<div id="creat">
<form action="./api/loginApi.php" method="post">
用戶:<input type="text" name="username"/><br><br>
密碼:<input type="password" name="password" /><br><br>
<input type="submit" value="提交"/>
<input type="reset" value="重置" />
</form>
<a href="register.html">沒有賬號?注冊</a> <a href="#">忘記密碼?找回</a>
</div>
</body>
</html>
2.注冊界面
<html>
<head>
<meta charset="utf-8">
<title>簡單的報名小操作</title>
<link rel="stylesheet" type="text/css" href="css/index.css" />
</head>
<body>
<h1>你還沒有賬號谦疾,請注冊</h1>
<div id="creat">
<form action="./api/registerApi.php" method="post">
用戶:<input type="text" name="username"/><br><br>
密碼:<input type="password" name="password"/><br><br>
<input type="submit" value="提交"/>
<input type="reset" value="重置" />
</form>
<a href="login.html">注冊完畢?登錄</a> <a href="#">忘記密碼?找回</a>
</div>
</body>
</html>
3.注冊php代碼
<?php
include_once("conn.php");
$username=$_POST['username'];
$password=$_POST['password'];
$sql="select count(*) as total from user where username='$username'";
$res=mysqli_query($con,$sql);
$row=mysqli_fetch_array($res);
$count=$row['total'];
if($count>0){
echo "用戶名已被占用";
?>
<a href="../register.html">返回注冊</a>
<?php
}else{
$sql="insert into user (password,username) values('$password', '$username')";
$res=mysqli_query($con,$sql);
if($res>0){
echo "注冊成功";
?>
<a href="../login.html">返回登錄</a>;
<?php
}else{
echo "注冊失敗";
?>
<a href="../login.html">返回登錄</a>;
<?php
}
mysqli_close($con);
?>
4.登錄密碼
<?php
include_once("conn.php");
$username=$_POST['username'];
$password=$_POST['password'];
$sql="select password as total from user where username='$username'";
$res=mysqli_query($con, $sql);
$row=mysqli_fetch_array($res);
if(!$row[0]){
echo "用戶名不存在";
?>
<a href="../register.html">返回注冊</a>
<?php
}else if ($row[0] !=$_POST['password']){
echo "密碼不正確";
?>
<a href="../login.html">返回登錄</a>
<?php
}else{
echo"用戶名和密碼匹配";
?>
<a href="../success.html">確定</a>
<?php
}
mysqli_close($con);
?>
5.登錄成功
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>歡迎進入</h1>
<a href="login.html">退出登陸</a>
</body>
</html>
6.圖片
qq_pic_merged_1586507468154.jpg
qq_pic_merged_1586507493035.jpg
qq_pic_merged_1586507434483.jpg
7.注意點
每個人庫名不一樣,注意修改
在瀏覽器上要寫127.0.01來訪問
每個php記得關(guān)閉數(shù)據(jù)庫
php和c很相似距芬,比如if語句使用,php變量要加$