captcha.php

20

Arun Kr.
29-Sep-25
<?php session_start();

	$f = rand(1,5);
	$s = rand(1,5);
	//////////////////////////////////////
	$op = array("+","x");
	$choseop = $op[rand(0,1)];
	$ans=0;
	switch ($choseop)
	{
		case '+':
			$ans = $f + $s;
		break;		

		case 'x':
			$ans = $f * $s;
		break;		
	}
	$str = $f.' '.$choseop.' '.$s;
	 //$str = md5(microtime());
	 //$str = substr($str,0,4);

	 ///////////////////////////////

	 $img = imagecreate(150,40);
	 imagecolorallocate($img, 225,225,225);
	 $text = imagecolorallocate($img,50,0,0);

	 //////////////////////////////
	 imagestring($img, 20, 50, 12, $str,$text);

	 header('Content: image/jpeg');

	 ////////////////////////////////
	 imagejpeg($img);

	 //////////////////////////////
	 imagedestroy($img);

$_SESSION['code'] = $ans;
?>
@Since 2024 Arun'Log Powered by Arun Git