13.2.1 設計驗證碼類
code.php
<?php
//開啟session
session_start();
include "vcode.class.php";
//構造方法
$vcode = new Vcode(80, 25, 4);
//將驗證碼放到服務器自己的空間保存一份
$_SESSION = $vcode->getcode();
//將驗證碼圖片輸出
$vcode->outimg();
reg.php
<body>
<form action="reg.php" method="post">
username: <input type="text" name="username"> <br>
password: <input type="password" name="password"> <br>
code: <input type="text" size="4" name="code">
[站外圖片上傳中……(1)] <br>
<input type="submit" name="dosubmit" value="登 錄"> <br>
</form>
</body>
vcode.class.php
<?php
class Vcode {
//構造方法柏肪, 三個參數(shù)
function __construct($width, $height, $num) {
}
//獲取字符的驗證碼, 用于保存在服務器中
function getcode() {
}
//輸出圖像
function outimg() {
}
}