PHP Classic Project Case-(a) blog management System 2

Source: Internet
Author: User

This article gives the database design, and the first page interface implementation, verification code implementation code.

V. Design of the database

1. Database table structure

2, the article table

3. Registered User Form


4. Picture table


5. Article Comment form


6, Comment reply form


7. Notice form


8. Friends Table


Six, home Verification code implementation (learn from others)

verifycode.php

<?php  /* Picture Verification Code    *  /Session_Start ();  $num =4;//Verification Code number  $width =60;//Verification Code width  $height =18;//Verification code height  $code = ";  for ($i =0; $i < $num; $i + +)//Generate verification code  {   switch (rand (0,2))   {case    0: $code [$i]=CHR (rand (48,57)); break;//Digit Case    1: $code [$i]=CHR (rand (65,90)); break;//Capital Letter Case    2: $code [$i]=CHR (rand (97,122)); break;// Lowercase letter   }  }  $_session["Verifycode"]= $code;//Use SESSION to authenticate  $image =imagecreate ($width, $ height);  Imagecolorallocate ($image, 255,255,255);  for ($i =0; $i <80; $i + +)//Generate interference pixels  {   $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 + +)//print characters to image  {   $char _color=imagecolorallocate ($image, Rand (0,2555), Rand (0,255), Rand (0,255));   Imagechar ($image, Max, ($width/$num) * $i, Rand (0,5), $code [$i], $char _color);  }  Header ("Content-type:image/png");  Imagepng ($image);//output image to browser  

Use this form on the first page to log in to the column:

<form action= "login.php" method= "POST" ><span style= "white-space:pre" ></span> user name: <input type= " Text "name=" username "id=" username "size="/>        password: <input type= "password" name= "password" id= "password" Size= "Ten"/>        captcha: <input type= "text" name= "Chknum" id= "Chknum" size= "ten"/>         <input name=" Submit "type= "Submit" value= "Login" style= "font-size:9pt"/></form>
Add response action on captcha picture, refresh Captcha onclick= "Javascript:refresh_code ()"

Implement this action in the JS file

function Refresh_code () {document.getElementById (' Imgcode '). src= "Verifycode.php?a=" +math.random ();
The A value passed is only for refresh, that is, loading a different code page, also implemented a refresh.





PHP Classic Project Case-(a) blog management System 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.