php经典实例博客管理,PHP经典项目案例-(一)博客管理系统2
本篇給出數據庫設計,及首頁界面實現,驗證碼實現代碼。
五、數據庫設計
1、數據庫表結構
2、文章表
3、注冊用戶表
4、圖片表
5、文章評論表
6、評論回復表
7、公告表
8、好友表
六、首頁驗證碼實現(借鑒別人的)
verifycode.php
/*
圖片驗證碼
*/
session_start();
$num=4;//驗證碼個數
$width=60;//驗證碼寬度
$height=18;//驗證碼高度
$code=' ';
for($i=0;$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
{
$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);//釋放資源
?>
在首頁登陸那一欄使用這一表單:
用戶名:
密碼:
驗證碼:
在驗證碼圖片上添加響應動作,刷新驗證碼onClick="javascript:refresh_code()"
在js文件里實現這個動作
function refresh_code()
{
document.getElementById('imgcode').src="verifycode.php?a="+Math.random();
}傳遞的a值只是為了實現刷新,也就是加載不同的驗證碼頁面,也就實現了刷新。
原文:http://blog.csdn.net/u014470702/article/details/41774821
總結
以上是生活随笔為你收集整理的php经典实例博客管理,PHP经典项目案例-(一)博客管理系统2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Centos7 新建server的优化脚
- 下一篇: 以太坊学习路线——(三)Solidity