查询某个数据库的内容的话,建个HTML文件,然后建个from表单,例子如下。
<form action="./loginchuli.php" method="post"> <div>用户名:<input type="text" name="uid" /></div> <div>密码:<input type="password" name="pwd" /></div> <div><input type="submit" disabled="disabled" value="登录" onclick="return check()" /></div> </form>
然后写php文件连接数据库
$uid = $_POST["uid"]; $pwd = $_POST["pwd"]; $db = new MySQLi("localhost","root","123","mydb"); if(mysqli_connect_error()){ die("连接失败!"); } $sql = "select pwd from users where uid='{$uid}'"; $reslut = $db->query($sql); $arr = $reslut->fetch_row(); if($arr[0]==$pwd && !empty($pwd)){ echo "<script>window.location.href='main.php'</script>"; }else{ header("location:login.php"); }
这边要注意账号密码的严谨性