Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Formularz a kodowanie
Draraki
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 2.08.2012

Ostrzeżenie: (0%)
-----


Otóż mam taki problem smile.gif
Zrobiłem taki jakiś formularz ale niestety coś mu odbiło biggrin.gif Robiłem według tego klik
Bez grafiki działał bez zastrzeżeń, lecz gdy zrobiłem jakąś kiepską grafikę w photoshopie i próbuję zakodować wszystko mam problem przy formularzu.
Otóż bez tokena wysyła wszystko poprawnie, lecz gdy wpiszę token (prawidłowy lub nie) to i tak wyświetla że niepoprawny i nie wysyła.
link do formularza
Bawię się z tym, ale szukam chyba czegoś czego nie wiem biggrin.gif
Tu moje pliczki:

index.php
  1. <html>
  2. <head>
  3. <link rel="stylesheet" href="style.css" type="text/css">
  4. <title>Poland Haxball</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  6. </head>
  7. <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  8. <form action="wysylka.php" method="post">
  9. <table id="Tabela_01" width="1281" height="1281" border="0" cellpadding="0" cellspacing="0">
  10. <tr>
  11. <td colspan="17">
  12. <img src="images/Bez-nazwy-1_01.gif" width="1280" height="61" alt=""></td>
  13. <td>
  14. <img src="images/spacer.gif" width="1" height="61" alt=""></td>
  15. </tr>
  16. <tr>
  17. <td colspan="2" rowspan="9">
  18. <img src="images/Bez-nazwy-1_02.gif" width="169" height="424" alt=""></td>
  19. <td colspan="3">
  20. <img src="images/Bez-nazwy-1_03.gif" width="160" height="75" alt=""></td>
  21. <td rowspan="3">
  22. <img src="images/Bez-nazwy-1_04.gif" width="110" height="176" alt=""></td>
  23. <td colspan="4">
  24. <img src="images/Bez-nazwy-1_05.gif" width="149" height="75" alt=""></td>
  25. <td rowspan="3">
  26. <img src="images/Bez-nazwy-1_06.gif" width="99" height="176" alt=""></td>
  27. <td>
  28. <img src="images/Bez-nazwy-1_07.gif" width="146" height="75" alt=""></td>
  29. <td colspan="2" rowspan="3">
  30. <img src="images/Bez-nazwy-1_08.gif" width="117" height="176" alt=""></td>
  31. <td>
  32. <img src="images/Bez-nazwy-1_09.gif" width="146" height="75" alt=""></td>
  33. <td colspan="2" rowspan="9">
  34. <img src="images/Bez-nazwy-1_10.gif" width="184" height="424" alt=""></td>
  35. <td>
  36. <img src="images/spacer.gif" width="1" height="75" alt=""></td>
  37. </tr>
  38. <tr>
  39. <td colspan="3" rowspan="2">
  40. <img src="images/Bez-nazwy-1_11.gif" width="160" height="101" alt=""></td>
  41. <td colspan="4" rowspan="2">
  42. <img src="images/Bez-nazwy-1_12.gif" width="149" height="101" alt=""></td>
  43. <td rowspan="2">
  44. <img src="images/Bez-nazwy-1_13.gif" width="146" height="101" alt=""></td>
  45. <td>
  46. <img src="images/Bez-nazwy-1_14.gif" width="146" height="92" alt=""></td>
  47. <td>
  48. <img src="images/spacer.gif" width="1" height="92" alt=""></td>
  49. </tr>
  50. <tr>
  51. <td rowspan="2">
  52. <button type="submit" class="send"></button>
  53. </td>
  54. <td>
  55. <img src="images/spacer.gif" width="1" height="9" alt=""></td>
  56. </tr>
  57. <tr>
  58. <td colspan="2" rowspan="2">
  59. <img src="images/Bez-nazwy-1_16.gif" width="141" height="85" alt=""></td>
  60. <td colspan="9">
  61. <textarea type="text" name="wpis" value="<? echo $_POST['wpis']; ?>" class="pole">Wpisz tutaj swój tekst.</textarea></td>
  62. <td rowspan="6">
  63. <img src="images/Bez-nazwy-1_18.gif" width="35" height="248" alt=""></td>
  64. <td>
  65. <img src="images/spacer.gif" width="1" height="40" alt=""></td>
  66. </tr>
  67. <tr>
  68. <td colspan="9">
  69. <img src="images/Bez-nazwy-1_19.gif" width="605" height="45" alt=""></td>
  70. <td rowspan="5">
  71. <img src="images/Bez-nazwy-1_20.gif" width="146" height="208" alt=""></td>
  72. <td>
  73. <img src="images/spacer.gif" width="1" height="45" alt=""></td>
  74. </tr>
  75. <tr>
  76. <td rowspan="4">
  77. <img src="images/Bez-nazwy-1_21.gif" width="140" height="163" alt=""></td>
  78. <td colspan="4" rowspan="3">
  79. <textarea type="text" name="token" class="captcha"></textarea></td>
  80. <td colspan="6">
  81. <img src="images/Bez-nazwy-1_23.gif" width="437" height="7" alt=""></td>
  82. <td>
  83. <img src="images/spacer.gif" width="1" height="7" alt=""></td>
  84. </tr>
  85. <tr>
  86. <td rowspan="3">
  87. <img src="images/Bez-nazwy-1_24.gif" width="16" height="156" alt=""></td>
  88. <td>
  89. <div id=captcha><?
  90. $slowa=file('hasla.txt');
  91. $id=rand(0,count($slowa)-1);
  92.  
  93. echo '<img src="pic.php?id='.$id.'">'
  94.  
  95. ?></div>
  96. </td>
  97. <td colspan="4" rowspan="3">
  98. <img src="images/Bez-nazwy-1_26.gif" width="361" height="156" alt=""></td>
  99. <td>
  100. <img src="images/spacer.gif" width="1" height="20" alt=""></td>
  101. </tr>
  102. <tr>
  103. <td rowspan="2">
  104. <img src="images/Bez-nazwy-1_27.gif" width="60" height="136" alt=""></td>
  105. <td>
  106. <img src="images/spacer.gif" width="1" height="7" alt=""></td>
  107. </tr>
  108. <tr>
  109. <td colspan="4">
  110. <img src="images/Bez-nazwy-1_28.gif" width="169" height="129" alt=""></td>
  111. <td>
  112. <img src="images/spacer.gif" width="1" height="129" alt=""></td>
  113. </tr>
  114. <tr>
  115. <td rowspan="2">
  116. <img src="images/Bez-nazwy-1_29.gif" width="128" height="795" alt=""></td>
  117. <td colspan="15">
  118. <img src="images/Bez-nazwy-1_30.png" width="1024" height="695" alt=""></td>
  119. <td rowspan="2">
  120. <img src="images/Bez-nazwy-1_31.gif" width="128" height="795" alt=""></td>
  121. <td>
  122. <img src="images/spacer.gif" width="1" height="695" alt=""></td>
  123. </tr>
  124. <tr>
  125. <td colspan="15">
  126. <img src="images/Bez-nazwy-1_32.gif" width="1024" height="100" alt=""></td>
  127. <td>
  128. <img src="images/spacer.gif" width="1" height="100" alt=""></td>
  129. </tr>
  130. <tr>
  131. <td>
  132. <img src="images/spacer.gif" width="128" height="1" alt=""></td>
  133. <td>
  134. <img src="images/spacer.gif" width="41" height="1" alt=""></td>
  135. <td>
  136. <img src="images/spacer.gif" width="140" height="1" alt=""></td>
  137. <td>
  138. <img src="images/spacer.gif" width="1" height="1" alt=""></td>
  139. <td>
  140. <img src="images/spacer.gif" width="19" height="1" alt=""></td>
  141. <td>
  142. <img src="images/spacer.gif" width="110" height="1" alt=""></td>
  143. <td>
  144. <img src="images/spacer.gif" width="39" height="1" alt=""></td>
  145. <td>
  146. <img src="images/spacer.gif" width="16" height="1" alt=""></td>
  147. <td>
  148. <img src="images/spacer.gif" width="60" height="1" alt=""></td>
  149. <td>
  150. <img src="images/spacer.gif" width="34" height="1" alt=""></td>
  151. <td>
  152. <img src="images/spacer.gif" width="99" height="1" alt=""></td>
  153. <td>
  154. <img src="images/spacer.gif" width="146" height="1" alt=""></td>
  155. <td>
  156. <img src="images/spacer.gif" width="82" height="1" alt=""></td>
  157. <td>
  158. <img src="images/spacer.gif" width="35" height="1" alt=""></td>
  159. <td>
  160. <img src="images/spacer.gif" width="146" height="1" alt=""></td>
  161. <td>
  162. <img src="images/spacer.gif" width="56" height="1" alt=""></td>
  163. <td>
  164. <img src="images/spacer.gif" width="128" height="1" alt=""></td>
  165. <td></td>
  166. </tr></form>
  167. </table>
  168. </body>
  169. </html>



pic.php
  1. <?
  2. $slowa=file('hasla.txt');
  3.  
  4. if(isset($_GET['id']))
  5. $nr=$_GET['id'];
  6. else $nr=rand(0,count($slowa)-1);
  7.  
  8. $slowo=$slowa[$nr];
  9. $wysokosc=20;
  10. $szerokosc=60;
  11.  
  12.  
  13. $pic=ImageCreate($szerokosc,$wysokosc);
  14. $bialy=ImageColorAllocate($pic,255,255,255);
  15. $czarny=ImageColorAllocate($pic,0,0,0);
  16. $szary=ImageColorAllocate($pic,150,150,150);
  17.  
  18. ImageFill($pic,1,1,$bialy);
  19. for($i=0;$i<200;$i++)
  20. {
  21. $los1=rand(0,$szerokosc);
  22. $los2=rand(0,$wysokosc);
  23.  
  24. ImageLine($pic,$los1,$los2,$los1,$los2,$szary);
  25. }
  26. for($i=0;$i<count($slowa);$i++)
  27. {
  28. $rozmiar=rand(2,5);
  29.  
  30. ImageString($pic,$rozmiar,$i*10+7,3,trim($slowo[$i]),$czarny);
  31. }
  32. Header("Content-type: image/gif");
  33. ImageGIF($pic);
  34. ?>



wysylka.php
<?
$id=$_POST['los'];
$odp=$_POST['token'];

$slowa=file('hasla.txt');

if(trim($slowa[$id])==$odp)
{
echo 'Token poprawny!';
//dalsze instrukcje, jeśli token jest poprawny

// odbieramy dane z formularza
$wpis = $_POST['wpis'];

if($wpis) {

// łączymy się z bazą danych
$connection = @mysql_connect('localhost', 'xxxxxxx', 'xxxxxxxxx')
or die('Brak połączenia z serwerem MySQL');
$db = @mysql_select_db('xxxxxxxxxx', $connection)
or die('Nie mogę połączyć się z bazą danych');

// dodajemy rekord do bazy
$ins = @mysql_query("INSERT INTO test SET wpis='$wpis'");

if($ins) echo "Wpis został dodany";
else echo "Błąd nie udało się dodać nowego wpisu";

mysql_close($connection);
}


}
else
{
echo 'Token niepoprawny!<br><br>';
include('index.php');
//dalsze instrukcje, jeśli token jest niepoprawny
}
?>


hasla.txt już nie wrzucam bo tam jest dobrze wszystko na pewno
Ten sam kod działał mi tutaj z tokenem:
klik

Gdzieś popełniłem błąd? biggrin.gif
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
CuteOne
post
Post #2





Grupa: Zarejestrowani
Postów: 2 958
Pomógł: 574
Dołączył: 23.09.2008
Skąd: wiesz, że tu jestem?

Ostrzeżenie: (0%)
-----


$nr=rand(0,count($slowa)-1); tak więc losujesz słowo ale po wysyłce form. nie wiesz jakie słowo wylosowałeś. Zapisz $nr do sesji a po wysyłce odczytaj ją i porównaj z $_POST['token']

ps. po kiego czorta ci potrzebny textarea do wpisywania jednego słowa??
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 19:46