文章插圖

文章插圖
利用PHP實現登錄與注冊功能以及使用PHP讀取mysql數據庫——以表格形式顯示數據登錄界面
<body>
<form action=”login1.php” method=”post”>
<div>用戶名:<input type=”text” name=”uid” /></div><br />
<div>密碼:<input type=”password” name=”pwd” /></div><br />
<div><input type=”submit” value=http://www.mnbkw.com/jxjc/190716/”登錄”/>
</form>
</body>
后臺登錄處理
<?php
$uid = $_POST[“uid”];
$pwd = $_POST[“pwd”];
【PHP實現登錄頁面 php實現登錄】$db = new MySQLi(“localhost”,”root”,””,”0710_info”);
if(mysqli_connect_error()){
die(“連接失敗”);
}
$sql = “select pwd from users where uid='{$uid}’”;
//echo $sql;
$result = $db->query($sql);
$arr = $result->fetch_row();
//防止sql注入攻擊
if($arr[0]==$pwd && !empty($pwd)){
//跳轉到主界面(php方式)
header(“location:register_system.php”);
//JS跳轉頁面方式
/*echo “<script>
window.location.href=http://www.mnbkw.com/jxjc/190716/’register_system.php’
</script>”;*/
}else{
header(“location:login_system.php”);
}
?>
注冊界面
<body>
<form action=”register1.php” method=”post” >
<div style=”font-size:20px; font-weight:1000; font-family:微軟雅黑; margin-left:50px; margin-bottom:20px”>用戶注冊</div>
<div>用戶名:<input type=”text” name=”uid” /></div><br />
<div>登錄密碼:<input type=”password” name=”pwd” /></div><br />
<div>姓名:<input type=”text” name=”name” /></div><br />
<div>性別:
<input type=”radio” name=”sex” value=http://www.mnbkw.com/jxjc/190716/”1″ />男
<input type=”radio” name=”sex” value=http://www.mnbkw.com/jxjc/190716/”0″ />女
</div><br />
<div><input type=”submit” value=http://www.mnbkw.com/jxjc/190716/”注冊” onclick=”return check()”/>
