使用PHP实现登录与注册功能以及使用PHP读取mysql资料库——以表格形式展现资料
<body>
<form action=”login1.php” method=”post”>
<div>客户名:<input type=”text” na小学数学评课用语me=”uid” /></div><br />
<div>密码:<inp五年级试卷ut type=”password” name=”pwd” /></div><br />
<div><input type=”submit” value=”登录”/></div>
</form>
</body>
<?php
$uid = $_POST[“uid”];
$pwd = $_POST[“pwd”];
$db = new MySQLi(“localhost”,”root”,””,”0710_info”);
if(mysqli_connect_error()){
die(“连接失败”);
}
$sql = “lect pwd from urs 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=’register_system.php’
</script>”;*/
}el{
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=”x” value=”1″ />男
<input type=”radio” name=”x” value=”0″ />女
</div><br />
<div><input type=”submit” value=”注册” onclick=”return check()”/></div>
</form>
</body>
<scri梦见血是什么意思pt>
function check(){
var uid = document.getElementsByTagName(“input”)[0].value;
if(uid == “”){
alert(“请输入客户名!”);
return fal;
}
var pwd = document.getElementsByTagName(“input”)[1].value;
if(pwd == “”){
alert(“请输入密码!”);
return fal;
}
var name = document.getElementsByTagName(“input”)[2].value;
if(name == “”){
alert(“请输入姓名!”);
return fal;
}
}
</script>
<?php
$uid = $_POST[“uid”];
$pwd = $_POST[“pwd”];
乘风破浪会有时$name = $_POST[“name”];
$x = $_POST[“x”];
$db = new MySQLi(“localhost”,”root”,””,”0710_info”);
if(mysqli_connect_error()){
die(“连接失败”);
}
$sql = “inrt into urs values(‘{$uid}’,'{$pwd}’,'{$name}’,{$x})”;
$r = $db->query($sql);
if($r){
echo “注册成功!”;
}el{
echo “注册失败!”;
}
?>
<body>
<table width=”50%” border=”1″>
<tr>
<td>代号</td>
<td>姓名</td>
<td>性别</td>
<td>生日</td>
<td>民族</td>
</tr>
<?php
$db = new MySQLi(“localhost”,”root”,””,”0710_info”);
$sql = “lect info.code,info.name,x,birthday,nation.name from info join nation on info.nation=nation.code”;//联动查询
$result = $db->query($sql);
$arr = $result->fetch_all();
//var_dump($arr);
//使用foreach循环遍历全部资料
foreach($arr as $v){
$x = $v[2]?’男’:’女’;//使用三元运算符判断性别
echo “<tr>
<td>{$v[0]}</td>
<td>{$v[1]}</td>
<td>{$x}</td>
<td>{$v[3]}</td>
<td>{$v[4]}</td>
</tr>”;
}
?>
</table>
</body>
本文发布于:2023-03-31 19:15:28,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/1d92899244bf38f17c13ef17c76fb884.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:php登录页面实现(php简单的登录页面代码).doc
本文 PDF 下载地址:php登录页面实现(php简单的登录页面代码).pdf
留言与评论(共有 0 条评论) |