PHP经典项目案例-(一)博客管理系统2
本篇给出数据库设计,及首页界面实现,验证码实现代码。
五、数据库设计
1、数据库表结构

2、文章表
立即学习“PHP免费学习笔记(深入)”;

3、注册用户表

4、图片表

5、文章评论表

6、评论回复表

7、公告表
该模板源码有公司简介、公司新闻、产品展示、客户案例、留言等企业官网常用页面功能。模板是响应式模板,支持多语言,完善的标签调用修改起来很方便。功能特点:1. 使用的框架采用HkCms开源内容管理系统v2.2.3版本、免费可以商用。2. 所需环境Apache/Nginx,PHP7.2 及以上 + MySQL 5.6 及以上。3. 安装教程: (1) 站点运行路径填写到public目录下。 (2) 浏览
1

8、好友表

六、首页验证码实现(借鉴别人的)
verifycode.php
<?php /* 图片验证码 */ session_start(); $num=4;//验证码个数 $width=60;//验证码宽度 $height=18;//验证码高度 $code=' '; for($i=0;$i<$num;$i++)//生成验证码 { switch(rand(0,2)) { case 0:$code[$i]=chr(rand(48,57));break;//数字 case 1:$code[$i]=chr(rand(65,90));break;//大写字母 case 2:$code[$i]=chr(rand(97,122));break;//小写字母 } } $_SESSION["VerifyCode"]=$code;//使用session用于登陆时验证 $image=imagecreate($width,$height); imagecolorallocate($image,255,255,255); for($i=0;$i<80;$i++)//生成干扰像素 { $dis_color=imagecolorallocate($image,rand(0,255),rand(0,255),rand(0,255)); imagesetpixel($image,rand(1,$width),rand(1,$height),$dis_color); } for($i=0;$i<$num;$i++)//打印字符到图像 { $char_color=imagecolorallocate($image,rand(0,2555),rand(0,255),rand(0,255)); imagechar($image,30,($width/$num)*$i,rand(0,5),$code[$i],$char_color); } header("Content-type:image/png"); imagepng($image);//输出图像到浏览器 imagedestroy($image);//释放资源?> <form action="login.php" method="post"><span style="white-space:pre"> </span>用户名:<input type="text" name="username" id="username" size="10" /> 密码:<input type="password" name="password" id="password" size="10" /> 验证码:<input type="text" name="chknum" id="chknum" size="10" /> <img id="imgcode" src="VerifyCode.php" alt="验证码" align="bottom" onClick="javascript:refresh_code()"/> <input name="submit" type="submit" value="登陆" style="max-width:90%"/></form>
在js文件里实现这个动作
function refresh_code(){ document.getElementById('imgcode').src="verifycode.php?a="+Math.random();}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
C++高性能并发应用_C++如何开发性能关键应用
Java AI集成Deep Java Library_Java怎么集成AI模型部署
Golang后端API开发_Golang如何高效开发后端和API
Python异步并发改进_Python异步编程有哪些新改进
C++系统编程内存管理_C++系统编程怎么与Rust竞争内存安全
Java GraalVM原生镜像构建_Java怎么用GraalVM构建高效原生镜像
Python FastAPI异步API开发_Python怎么用FastAPI构建异步API
C++现代C++20/23/26特性_现代C++有哪些新标准特性如modules和coroutines
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号