玫瑰小妖 2019-10-21
直接上代码吧
<?php header("Content-type: text/html; charset=utf-8"); //数据量链接 $conn=mysqli_connect("127.0.0.1",‘bc‘,"HGEAfZdSbaXHD5NA",‘test‘); //需求一 // 登陆验证密码 function checkuser($conn,$username,$password) { $res=0; $sql="select * from admin where username=‘".$username."‘"; $result=mysqli_query($conn,$sql); if($result) { $dinfo=mysqli_fetch_array($result);//取得一条记录 if($password==$dinfo[‘password‘]) { $res=1; } } return $res; } $username=‘admin‘; $password=‘123456‘; //使用方法 $res=checkuser($conn,$username,$password); echo $res; //需求二 //查询所有数据到表格 $sql="select * from admin"; $result=mysqli_query($conn,$sql); if($result) { $dinfo=mysqli_fetch_all($result);// echo "<table border=1><tr><td>序号</td><td>用户名</td><td>密码</td><tr>"; $i=1; foreach($dinfo as $k=>$v) { echo "<tr><td>".$i."</td><td>".$v[‘1‘]."</td><td>".$v[‘2‘]."</td></tr>"; $i++; } echo "</table>"; }
表结构和数据如下
效果如下
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh