Membuat Capcha pada PHP
Buat file php dengan nama captcha.php
<?php session_start(); $text = rand(10000,99999); $_SESSION["vercode"] = $text; $height = 25; $width = 65; $image_p = imagecreate($width, $height); $black = imagecolorallocate($image_p, 0, 0, 0); $white = imagecolorallocate($image_p, 255, 255, 255); $font_size = 14; imagestring($image_p, $font_size, 5, 5, $text, $white); imagejpeg($image_p, null, 80); ?>
buat file htmk dengan nama test.html
<form action="submit.php" method="post"> Comment: <textarea name="coment"></textarea><br>
Enter Code <img src="captcha.php"><input type="text" name="vercode" /><br> <input type="submit" name="Submit" value="Submit" /> </form>
buat file dengan nama submit.php
<?php session_start(); if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') { echo '<strong>Incorrect verification code.</strong><br>'; } else { // add form data processing code here echo '<strong>Verification successful.</strong><br>'; }; ?>
saya mendapatkan dari url: http://www.phpjabbers.com/captcha-image-verification-php19.html
mangtzab gan...
BalasHapus