Home Backend Development PHP Tutorial PHP经典项目案例-(1)博客管理系统2

PHP经典项目案例-(1)博客管理系统2

Jun 13, 2016 pm 12:11 PM
code image quot rand

PHP经典项目案例-(一)博客管理系统2

本篇给出数据库设计,及首页界面实现,验证码实现代码。

五、数据库设计

1、数据库表结构

2、文章表

3、注册用户表


4、图片表


5、文章评论表


6、评论回复表


7、公告表


8、好友表


六、首页验证码实现(借鉴别人的)

verifycode.php

<?php /*  图片验证码    */  session_start();  $num=4;//验证码个数  $width=60;//验证码宽度  $height=18;//验证码高度  $code=&#39; &#39;;  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);//释放资源?> 
Copy after login

在首页登陆那一栏使用这一表单:

Copy after login
用户名: 密码: 验证码: 验证码
在验证码图片上添加响应动作,刷新验证码onClick="javascript:refresh_code()"

在js文件里实现这个动作

function refresh_code(){	document.getElementById('imgcode').src="verifycode.php?a="+Math.random();}
Copy after login
传递的a值只是为了实现刷新,也就是加载不同的验证码页面,也就实现了刷新。





Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve 'undefined: rand.Seed' error in golang? How to solve 'undefined: rand.Seed' error in golang? Jun 25, 2023 am 08:34 AM

During the development or learning process of using Golang, we may encounter the error message of undefined:rand.Seed. This error usually occurs when you need to use a random number generator, because in Golang you need to set a random number seed before you can use the function in the rand package. This article will explain how to resolve this error. 1. Introduce the math/rand package. First, we need to introduce the math/rand package into the code. exist

How to use Bing Image Creator for free How to use Bing Image Creator for free Feb 27, 2024 am 11:04 AM

This article will introduce seven ways to get high-quality output using the free BingImageCreator. BingImageCreator (now known as ImageCreator for Microsoft Designer) is one of the great online artificial intelligence art generators. It generates highly realistic visual effects based on user prompts. The more specific, clear, and creative your prompts are, the better the results will be. BingImageCreator has made significant progress in creating high-quality images. It now uses Dall-E3 training mode, showing a higher level of detail and realism. However, its ability to consistently produce HD results depends on several factors, including fast

How to delete images from Xiaomi phones How to delete images from Xiaomi phones Mar 02, 2024 pm 05:34 PM

How to delete images on Xiaomi mobile phones? You can delete images on Xiaomi mobile phones, but most users don’t know how to delete images. Next is the tutorial on how to delete images on Xiaomi mobile phones brought by the editor. Interested users can come and join us. Let's see! How to delete images on Xiaomi mobile phone 1. First open the [Album] function in Xiaomi mobile phone; 2. Then check the unnecessary pictures and click the [Delete] button in the lower right corner; 3. Then click [Album] at the top to enter the special area , select [Recycle Bin]; 4. Then directly click [Empty Recycle Bin] as shown in the figure below; 5. Finally, directly click [Permanent Delete] to complete.

Edit your Unity project in Visual Studio Code and you are now ready to go Edit your Unity project in Visual Studio Code and you are now ready to go Aug 08, 2023 am 10:21 AM

Microsoft has released a preview version of the Unity extension for Visual Studio Code. This new Unity extension will allow you to write and debug Unity games. This new Unity extension brings some popular features already available in Visual Studio and Visual Studio Tools for Unity, making C# in Visual Studio Code better for Unity development. Currently, the Unity extension for VSCode provides the following: A Unity debugger for debugging your Unity editor and Unity player. Unity-specific C# analyzer and refactoring. Uni

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Imagemagic installation Centos and Image installation tutorial Imagemagic installation Centos and Image installation tutorial Feb 12, 2024 pm 05:27 PM

LINUX is an open source operating system. Its flexibility and customizability make it the first choice of many developers and system administrators. In the LINUX system, image processing is a very important task, and Imagemagick and Image are Two very popular image processing tools, this article will introduce you to how to install Imagemagick and Image in Centos system, and provide detailed installation tutorials. Imagemagic installation Centos tutorial Imagemagick is a powerful image processing toolset, which can perform various image operations under the command line. The following are the steps to install Imagemagick on Centos system: 1

How to solve the problem of generating the same random numbers using php rand function How to solve the problem of generating the same random numbers using php rand function Mar 23, 2023 am 09:17 AM

The rand() function uses the same initial seeds on each call. The default initial seed is obtained from the operating system's time, but it only has microsecond accuracy. That is, within a very short period of time, many rand() function calls will use the same initial seed, resulting in the same random number generation. So, how to solve this problem?

How to synchronize random number generation in Golang parallel processing? How to synchronize random number generation in Golang parallel processing? Jun 03, 2024 pm 02:53 PM

Synchronizing random number generation in Go concurrent programming: Use a mutex (sync.Mutex) to control access to the rand.Rand random number generator. Each goroutine acquires the mutex lock before generating random numbers and releases the mutex lock after generating it. This ensures that only one goroutine can access the random number generator at a time, eliminating data races.

See all articles