注册登录连接数据库
<!doctype html>
<html>
<head>
<title>用户注册</title>
<meta charset="UTF-8"> <!--放乱码-->
</head>
<body>
<?php
if(isset($_POST['zhanghu'])){ //isset() php内置函数
$conn=mysqli_connect("10.21.54.99","c60","123456","c60"); //mysql_connect() PHP连接数据库的函数
$xx="INSERT INTO `demo_tex`(`lz`,`xh`,`email`) VALUES ('".$_POST['zhanghu']."','".$_POST['password']."','".$_POST['email']."')"; //SQL的插入记录的命令
mysqli_query($conn,$xx); //PHP与数据库交互的函数,把$xx命令传送给数据库执行,并接受数据库返回的信息
echo $xx;
echo "写数据库成功";
exit;
}
?>
<div style="text-align:center;">
<div>欢迎注册</div>
<form action="" method="POST">
<div style="margin:10px auto;">
<laber>账号:</labe><input type="text" name="zhanghu"/>
</div>
<div style="margin:10px auto;">
<laber>密码:</labe><input type="text" name="password">
</div>
<div style="margin:10px auto;">
<laber>邮箱:</labe><input type="text" name="email">
</div>
<input type="submit" values="提交"/>
</form>
</div>
</body>
</html>
实现效果