Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Membuat Captcha dengan background berubah-ubah menggunakan PHP

0
Petama buat gambar background kemudian simpan di C:\xampp\htdocs dengan nama bg1.jpg , bg2.jpg , bg3. jpg , bg4.jpg , bg5.jpg

kode:
<?php
session_start();
$alpanumeric="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$random = substr(str_shuffle($alpanumeric),0,5);
$bg = rand(1, 5);
$image = imagecreatefromjpeg("bg$bg.jpg");
$textcolor = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 5, 5, 8, $random, $textcolor);
$_SESSION['image_random_value']=md5($random);
header('content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
?>





Membuat Captcha Dengan PHP

0


<?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, 50);
$backcolor = imagecolorallocate($image, 200, 200, 255);
$textColor = imagecolorallocate($image, 0, 0, 0);
$textColor1 = imagecolorallocate($image, 255, 0, 0);
$textColor2 = imagecolorallocate($image, 0, 200, 0);
$textColor3 = imagecolorallocate($image, 0, 0, 255);
$textColor4 = imagecolorallocate($image, 255, 255, 0);
$textColor5 = imagecolorallocate($image, 255, 0, 255);

imagestring ($image, 10, 20, 13, $random, $textColor);
imagestring ($image, 10, 30, 13, $random1, $textColor1);
imagestring ($image, 10, 40, 13, $random2, $textColor2);
imagestring ($image, 10, 50, 13, $random3, $textColor3);
imagestring ($image, 10, 60, 13, $random4, $textColor4);
imagestring ($image, 10, 70, 13, $random5, $textColor5);

//memberi nilai sesi
$_SESSION['image_random_value'] = md5($random);

header('Content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
?>

Membuat Gambar Wajah Menggunakan PHP

0


<?php
header("content-type: image/png");
$image = ImageCreate (250, 250);
$background = ImageColorAllocate ($image, 00, 33, 99);
$color = ImageColorAllocate($image, 206, 192, 215);
ImageEllipse ($image,120,120,175,175,$color) ; //Membuat lingkaran
ImageArc($image, 120, 140, 100, 70, 0, 180, $color); //Menggunakan Derajat
ImageRectangle($image,130,150,110,120,$color); //Kotak 'hidung'
ImageRectangle($image,130,150,120,120,$color); //Kotak 'hidung'
ImageFilledellipse($image,75,90,40,20,$color); //lingkaran 'Mata_1'
ImageFilledellipse($image,170,90,40,20,$color); //lingkaran 'Mata_2'
Imagepng ($image);