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