اخوانى
اواجة مشكلة فى الكابتشا كود
اولا كتبت صفحة الكابتشا بالكود التالى
<?php
session_start();
$image = imagecreatetruecolor(100,40);
$red = imagecolorallocate($image,255,255,255);
$yellow = imagecolorallocate($image,rand(1,255),rand(1,255),rand(1,255));
$lines = imagecolorallocatealpha($image,rand(1,200),rand(1,200),rand(1,200),rand(1,60));
$str ='';
$i=0;
$str=rand(10000,99999);
$_SESSION['code']=$str;
imagefill($image,0,0,$red);
imagettftext($image,20,0,0,30,$yellow,'STENCIL.ttf',$str);
for($i=0; $i<30; $i++){
imageline($image,rand(1,200),rand(1,200),rand(1,200),rand(1,200), $lines);
}
header('content=type: image/gif');
imagegif($image);
imagedestroy($image);
?>
وعرضت الصورة المحتوية على الكود فى الصفحة المطلوب عرض الصورة بها كالتالى
<img src='captcha.php' alt ='captcha code' border='1' />
وعلمت الصفحة تمام دون اى مشاكل ولكن احببت ان اعرض صورة اخرى للكود بصفحة اخرى يضيف بها المستخدم بيانات معينة فعرضت نفس الكود السابق فى الصفحة الجديدة ولكنها لم تعمل ابدا
قمت اثناء كتابة الكود بمحاولة عرض السيشن لارى مايأتى من صفحة الكابتشا ولكن لم تطبع اى شئ وعند ادخال نفس القيمة الظاهرة بالصورة تعطينى ان القيمة غير مطابقة
نسخت صفحة اخرى من صفحة الكابتشا واسميتها كابتشا1 واخذت منها السيشن الجديد ولكن نفس النتيجة
if (isset($_POST['capt1'])) /*this is the code i enter */ {
if (@$_SESSION['code'] == @$_POST['capt1']){ /*this is to match if the code i entered = the session of the captcha or not*/
$insertsay =mysql_query("INSERT INTO said
(title,subject,writer,date,email)
VALUES
('$title','$topic','$name','$date','$email')") or die("comments were not inserted");
if($insertsay){
echo"your data were entered to our database ";
}
}else {echo " <font color='red'><b> captcha code not match</b></font>";}
}else {echo "<font color='red'><b>you did not enter captcha code</b></font>";}
فى انتظار ردودكم اخوانى الاعزاء لاعرف كيف تعمل صفحة الكابتشا فى اكثر من صفحة لانة مازال امامى صفحتان اخرتان لاضع بهما كود الكابتشا