作为一个PHP的初学者,我试着写了一个留言板,页面有点丑,多多见谅,嘻嘻嘻
#我们写留言板需要用到数据库,所以我们先要建立三个表
user表
friend表
text表
#首先需要写一个注册与登录
##注册
zhuce.html
<meta charset="utf-8">
<title>zhuce</title>
</head>
<body>
<form method="POST" action="zhuce.php">
<div style="margin-left: 500px;margin-top:200px;height: 250px;width: 250px">
<h1>用户注册页面</h1>
用户名:<input type="text" name="username">
<div>密 码:<input type="password" name="password">
<div><input type="submit" name="submit" value="注册"></div>
</div>
</form>
</body>
zhuce.php
<?php
session_start();
header("Content-type: text/html; charset=utf-8"); //处理数据库用户名乱码
$user=$_POST["username"];
$pwd=$_POST["password"];
if($user==""||$pwd=="")
{
echo "<script>alert('请确认信息完整性!'); history.go(-1);</script>";
}
else
{
$link=mysqli_connect("localhost","root","","liuyan");//连接数据库
mysqli_query($link,"set names utf8");
$sql="select username from user where username='$_POST[username]'";
$result=mysqli_query($link,$sql);//执行sql语句