Basuically im making a math captcha, the user will have two numbers and an operator displayed in an image, this operator is then transformed from text to an math sysmbol using the if statments, however the '+' option is allways chosen even if the $operator variable dos'nt meet the requirements specified!😕
<?
session_start();
$operators=array('+',' add ',' plus ','*',' multiplied by ',' times ','-',' takeaway ',' minus ');
$first_num=rand(1,5);
$second_num=rand(6,11);
shuffle($operators);
$expression=$second_num.$operators[0].$first_num;
if ($operators[0]=='+'||'add'||'plus') {$task='+';}
elseif ($operators[0]=='*'||'multiplied by'||'times') {$task='*';}
else {$task='-';};
$text=array('W0rk 0ut...','Wh4t 15...','C41cu14t0r?');
shuffle($text);
eval("\$session_var=".$second_num.$task.$first_num.";");
$_SESSION['security_number']=$session_var;
$captcha_img=imagecreate(200,50);
$text_color = imagecolorallocate($captcha_img,32,32,32);
$text_color2 = imagecolorallocate($captcha_img,225,0,102);
$background_color= imagecolorallocate($captcha_img,241,241,241);
imagefill($captcha_img,0,0,$background_color);
imagettftext($captcha_img,30,rand(0,120),rand(10,70),rand(20,40),$text_color2,"../fonts/font2.ttf",$text[0]);
imagettftext($captcha_img,30,rand(-60,60),rand(60,120),rand(10,30),$text_color2,"../fonts/font2.ttf",$text[2]);
imagettftext($captcha_img,12,0,rand(0,40),rand(20,40),$text_color,"../fonts/font3.ttf",$expression);
$rand1=(rand(0,60));
header("Content-type:image/png");
header("Content-Disposition:inline ; filename=secure.jpg");
imagepng($captcha_img);
?>
Any help will be greatly apriciated,
Thanks!
Jamie Thompson