BERIKUT PTOGRAM TANTANGAN PHP DI SEKOLAH KU DAN INI CARA-CARA NYA
<?php
//captcha basic
session_start();
//membuat kata acak
$alphaNumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$random = substr(str_shuffle($alphaNumeric), 0,1);
$random1 = substr(str_shuffle($alphaNumeric), 0,1);
$random2 = substr(str_shuffle($alphaNumeric), 0,1);
$random3 = substr(str_shuffle($alphaNumeric), 0,1);
$random4 = substr(str_shuffle($alphaNumeric), 0,1);
$random5 = substr(str_shuffle($alphaNumeric), 0,1);
//membuat gambar dg background biru
$image = imagecreate (100, 40);
$backcolor = imagecolorallocate($image, 200, 200, 255);
$textColor = imagecolorallocate ($image, 255, 25, 25);
$textColor1 = imagecolorallocate ($image, 255, 255, 0);
$textColor2 = imagecolorallocate ($image, 233, 10, 150);
$textColor3 = imagecolorallocate ($image, 20, 200, 140);
$textColor4 = imagecolorallocate ($image, 155, 105, 250);
$textColor5 = imagecolorallocate ($image, 170, 0, 255);
imagestring ($image, 5, 20, 8, $random, $textColor);
imagestring ($image, 5, 30, 8, $random1, $textColor1);
imagestring ($image, 5, 40, 8, $random2, $textColor2);
imagestring ($image, 5, 50, 8, $random3, $textColor3);
imagestring ($image, 5, 60, 8, $random4, $textColor4);
imagestring ($image, 5, 70, 8, $random5, $textColor5);
//memberi nilai sesi
$_SESSION['image_random_value'] = md5($random);
$_SESSION['image_random_value'] = md5($random1);
$_SESSION['image_random_value'] = md5($random2);
$_SESSION['image_random_value'] = md5($random3);
$_SESSION['image_random_value'] = md5($random4);
$_SESSION['image_random_value'] = md5($random5);
header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
?>
Tidak ada komentar:
Posting Komentar
Berkomentarlah Jika Anda Tidak Mengerti,Berkomentarlah Dengan Sopan