php制作留言板

php留言板

利用php制作一个简单的留言板,可实现用户注册和登录,发表留言,修改留言,删除留言,查看留言

需要用到两张表,一张用来存储账号信息,另一张用来存储留言信息

user表

liuyan表

接下来是php代码

login_0.php

<form method ="POST" action = "login.php" name="frmLogin"> 
     <tr align="center" style="font-size:25px;"> 
           <td colspan="2" style="font-size:35px;">用户登陆</td></br>
     </tr>
       <tr>  
           <td align="center" style="font-size:25px;">用户名</td>  
           <td><input type="text" maxlength="16" name="username" placeholder="请输入账号" style="width:180px;font-size:20px;border-radius: 8px; "></td></br>
       </tr>  
       <tr>  
           <td align="center" style="font-size:25px;">密   码</td>  
           <td><input name="password" type="password" maxlength="16" placeholder="请输入密码" style="width:180px;font-size:20px;border-radius: 8px; "></td></br>
       </tr>
       <tr align="center"> 
           <td colspan="2">
           <input type="submit" name="denglu" value="登陆" class="btn">
           <input type="reset" name="rs" value="重置" class="btn">  
           <input type="button" name="zu" value="注册" onclick="window.location.href='register_0.php'" class="btn"/>  
           </td>  
       </tr> 
     </form>

<script type="text/javascript">
	// 验证输入不为空的脚本代码
	function checkForm(form) {
	if(form.username.value == "") {
	alert("用户名不能为空!");
	form.username.focus();
	return false;
	}
	if(form.password.value == "") {
	alert("密码不能为空!");
	form.password.focus();
	return false;
	}
	return true;
	}
</script>
</body>
</html>

login.php

<?php
	session_start();
	header("content-type:text/html;charset=utf-8");
	//连接数据库
	$conn = mysqli_connect("localhost","root","123456","liuyan");
	if (!$conn) {
		die("连接失败: " . mysqli_connect_error());
	}
	//接收$_POST用户名和密码
	$username = $_POST[&
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值