ugrás a tartalomhoz

$_SESSION és Captcha

Tanul0 · 2010. Már. 2. (K), 16.18
Üdvözletem!

Akadt egy kis problémám.

Adott egy captcha.php Nem én írtam, de átalakítottam.
  1. function random_string($len=5, $str='')  
  2.   {  
  3.     for($i=1; $i<=$len$i++)  
  4.         {  
  5.   
  6.   
  7.      $ord=rand(48, 90);  
  8.      if((($ord >= 48) && ($ord <= 57)) || (($ord >= 65) && ($ord<= 90)))  
  9.     $str.=chr($ord);  
  10.   
  11.   
  12.     else  
  13.         $str.=random_string(1);  
  14.     }  
  15.     return $str;  
  16.   
  17. }  
  18.   
  19. $rand_str=random_string(5);  
  20.   
  21.   
  22. $_SESSION['captcha']=md5($rand_str);  
  23.   
  24.   
  25.   
  26. $letter1=substr($rand_str,0,1);  
  27. $letter2=substr($rand_str,1,1);  
  28. $letter3=substr($rand_str,2,1);  
  29. $letter4=substr($rand_str,3,1);  
  30. $letter5=substr($rand_str,4,1);  
  31.   
  32.   
  33. $image=imagecreatefrompng("img/noise01.png");  
  34.   
  35.   
  36. $angle1 = rand(-20, 30);  
  37. $angle2 = rand(-30, 20);  
  38. $angle3 = rand(-20, 30);  
  39. $angle4 = rand(-30, 20);  
  40. $angle5 = rand(-20, 30);  
  41.   
  42.   
  43. $font1 = "./snipershot.ttf";  
  44. $font2 = "./snipershot.ttf";  
  45. $font3 = "./snipershot.ttf";  
  46. $font4 = "./snipershot.ttf";  
  47. $font5 = "./snipershot.ttf";  
  48.   
  49.   
  50. $colors[0]=array(122,229,112);  
  51. $colors[1]=array(85,178,85);  
  52. $colors[2]=array(226,108,97);  
  53. $colors[3]=array(141,214,210);  
  54. $colors[4]=array(214,141,205);  
  55. $colors[5]=array(100,138,204);  
  56.   
  57.   
  58. $color1=rand(0, 5);  
  59. $color2=rand(0, 5);  
  60. $color3=rand(0, 5);  
  61. $color4=rand(0, 5);  
  62. $color5=rand(0, 5);  
  63.   
  64.   
  65. $textColor1 = imagecolorallocate ($image$colors[$color1][0],$colors[$color1][1], $colors[$color1][2]);  
  66. $textColor2 = imagecolorallocate ($image$colors[$color2][0],$colors[$color2][1], $colors[$color2][2]);  
  67. $textColor3 = imagecolorallocate ($image$colors[$color3][0],$colors[$color3][1], $colors[$color3][2]);  
  68. $textColor4 = imagecolorallocate ($image$colors[$color4][0],$colors[$color4][1], $colors[$color4][2]);  
  69. $textColor5 = imagecolorallocate ($image$colors[$color5][0],$colors[$color5][1], $colors[$color5][2]);  
  70.   
  71. $size = 35;  
  72. $size2 = rand(15, 30);  
  73.   
  74. imagettftext($image$size$angle1, 10, $size+$size2$textColor1$font1$letter1);  
  75. imagettftext($image$size$angle2, 50, $size+$size2$textColor2$font2$letter2);  
  76. imagettftext($image$size$angle3, 110, $size+$size2$textColor3$font3$letter3);  
  77. imagettftext($image$size$angle4, 140, $size+$size2$textColor4$font4$letter4);  
  78. imagettftext($image$size$angle5, 190, $size+$size2$textColor5$font5$letter5);  
  79.   
  80. header('Content-type: image/jpeg');  
  81.   
  82. imagejpeg($image);  
  83.   
  84. imagedestroy($image);  
session elindítva az index.php-ban

reg.php-ban azonban nem találja a $_SESSION['captcha'] , a reg.php be van ágyazva az index.php-ba.

a captcha.php-t egy html templateben hívom meg <img src="captcha.php" alt="Kod" /> a templatet meg a reg.php-ban
  1. eval ("\$reg_template = \"".html_template("register")."\";");  
  2. echo $reg_template;  
Mi lehet a probléma?
 
1

Bocsánat! Megvan mi volt a

Tanul0 · 2010. Már. 2. (K), 17.10
Bocsánat! Megvan mi volt a hiba. A captcha.php-ban is el kell indítani a sessiont méghozzá ugyan olyna néven mint az index.php-ban.

Túl gyorsan pánikoltam