Pembangunan PHP kod lengkap sistem pengurusan latar belakang buku ringkas log masuk
Dalam bahagian ini kami mencipta fail login.php untuk memaparkan kod fungsi log masuk lengkap
Terdahulu kami mencipta fail style.css dan meletakkan fail CSS ini dalam folder yang sama. Seterusnya, panggil gaya CSS secara langsung.
Perkenalkan pangkalan data fail awam config.php.
<?php require_once("config.php"); //引入數(shù)據(jù)庫(kù)文件 ?> <?php if($_POST["Submit"]) { $username=$_POST["username"]; $pwd=$_POST["pwd"]; $code=$_POST["code"]; if($code<>$_SESSION["auth"]) { echo "<script language=javascript>alert('驗(yàn)證碼不正確!');window.location='login.php'</script>"; ?> <?php die(); } $SQL ="SELECT * FROM admin where username='$username' and password='$pwd'"; $rs=mysqli_query($link,$sql); if(mysqli_num_rows($rs)==1) { $_SESSION["pwd"]=$_POST["pwd"]; $_SESSION["admin"]=session_id(); echo "<script language=javascript>alert('登陸成功!');window.location='admin_index.php'</script>"; } else { echo "<script language=javascript>alert('用戶名或密碼錯(cuò)誤!');window.location='login.php'</script>"; ?> <?php die(); } } ?> <?php if($_GET['tj'] == 'out'){ session_destroy(); echo "<script language=javascript>alert('退出成功!');window.location='login.php'</script>"; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>圖書(shū)后臺(tái)管理系統(tǒng)登陸功能</title> <!-- 引入CSS樣式 --> <link rel="stylesheet" type="text/css" href="style.css"/> </head> <body> <div id="top"> </div> <form id="frm" name="frm" method="post" action="" onSubmit="return check()"> <div id="center"> <div id="center_left"></div> <div id="center_middle"> <div class="user"> <label>用戶名: <input type="text" name="username" id="username" /> </label> </div> <div class="user"> <label>密 碼: <input type="password" name="pwd" id="pwd" /> </label> </div> <div class="chknumber"> <label>驗(yàn)證碼: <input name="code" type="text" id="code" maxlength="4" class="chknumber_input" /> </label> <img src="verify.php" style="vertical-align:middle" /> </div> </div> <div id="center_middle_right"></div> <div id="center_submit"> <div class="button"> <input type="submit" name="Submit" class="submit" value=" "> </div> <div class="button"><input type="reset" name="Submit" class="reset" value=""> </div> </div> <div id="center_middle_right"></div> </div> </form> <div id="footer"></div> </body> </html>