Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Problem z if_em
robootb
post
Post #1





Grupa: Zarejestrowani
Postów: 56
Pomógł: 0
Dołączył: 6.03.2007

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


  1. <?php
  2. if ($_POST['si'] == true) {
  3.  
  4. if ($monety < $ksila)
  5. echo("brak kasy");
  6.  
  7. else
  8.  
  9. if ($monety > $ksila)
  10. $monety = $monety - $ksila;
  11. $sila = $sila +1;
  12.  
  13. $file11 = "user/$login/staty/sila.txt";
  14. $fp = fopen($file11, "w");
  15. $dane="$sila";
  16.  
  17.  flock($fp, 2);
  18.  fwrite($fp, $dane);
  19.  flock($fp, 3);
  20.  fclose($fp);
  21. } 
  22. ?>

Co jest zle ? Kiedy spelnia pierwszy warunek wyswietla brak kasy, a pozniej i tak to wykonuje
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
robootb
post
Post #2





Grupa: Zarejestrowani
Postów: 56
Pomógł: 0
Dołączył: 6.03.2007

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


  1. <?php ob_start(); ?>
  2. <?php
  3. ini_set('display_errors', 1);
  4. ?>
  5.  
  6. <html>
  7.  
  8. <head>
  9. <meta http-equiv="Content-Language" content="pl">
  10. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  11. <title>aaa</title>
  12. </head>
  13. <LINK href="style.css" type=text/css rel=stylesheet>
  14.  
  15.  
  16. <body bgcolor="#DED3B9">
  17.  
  18. <TABLE class=blind cellSpacing=0 id="table1" width="961" height="133">
  19. <TR>
  20. <TD height="133">
  21. <p align="center">
  22. <img border="0" src="logo.jpg" width="957" height="147"></TD></TR></TABLE>
  23. <TABLE class=blind cellSpacing=0 id="table2" width="955" height="544">
  24. <tr>
  25. <TD width="132" height="40" nowrap> &nbsp;</TD>
  26. <TD width="819" height="544" rowspan="8">
  27.  
  28. <p align="center">
  29.  
  30. <?php
  31. $login = "$var";
  32. $fp = fopen("user/$login/staty/sila.txt", "r");
  33. $sila = fread($fp, 4);
  34. $fp1 = fopen("user/$login/staty/zrecznosc.txt", "r");
  35. $zrecznosc =fread($fp1, 4);
  36. $fp2 = fopen("user/$login/staty/zwinnosc.txt", "r");
  37. $zwinnosc =fread($fp2, 4);
  38. $fp3 = fopen("user/$login/staty/inteligencja.txt", "r");
  39. $inteligencja = fread($fp3, 4);
  40. $fp4 = fopen("user/$login/staty/wytrzymalosc.txt", "r");
  41. $wytrzymalosc = fread($fp4, 4);
  42. $fp5 = fopen("user/$login/staty/monety.txt", "r");
  43. $monety = fread($fp5, 25);
  44. $ksila = $sila * 23;
  45. $kzrecznosc = $zrecznosc * 23;
  46. $kzwinnosc = $zwinnosc * 23;
  47. $kinteligencja = $inteligencja * 23;
  48. $kwytrzymalosc = $wytrzymalosc * 23;
  49. ?>
  50.  
  51. <font size="6">Statystyki :</font> 
  52. </p>
  53. <p align="center">
  54.  
  55. &nbsp;</p>
  56. <p align="left">
  57.  
  58. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  59. </p>
  60. <FORM action="postac.php" method="post">
  61. <table border="1" width="100%" id="table3">
  62. <tr>
  63. <td width="98">Siła </td>
  64. <td width="112"> 
  65. <input type="text" readonly value="<?php echo $sila; ?>" SIZE=3 class="klasa" width=30 height=30 name="T1" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  66. </td>
  67. <td width="55">  
  68. <input type="button" value="+1" name="si" ></td></td>
  69. </form>
  70. <?php
  71. if ($_POST['si'] == true) {
  72.  
  73. if ($monety < $ksila)
  74. echo('Brak kasy');
  75. else
  76.  
  77. if ($monety > $ksila){
  78. $monety = $monety - $ksila;
  79. $sila = $sila +1;
  80.  
  81. $file11 = "user/$login/staty/sila.txt";
  82. $fp = fopen($file11, 'w');
  83. $dane=$sila;
  84.  
  85.  flock($fp, 2);
  86.  fwrite($fp, $dane);
  87.  flock($fp, 3);
  88.  fclose($fp);
  89.  
  90. $file12 = "user/$login/staty/monety.txt";
  91. $fp = fopen($file12, 'w');
  92. $dane1=$monety;
  93.  
  94.  flock($fp, 2);
  95.  fwrite($fp, $dane1);
  96.  flock($fp, 3);
  97.  fclose($fp);
  98.  
  99.  
  100. }
  101. }
  102. ?>
  103.  
  104.  
  105.  
  106. <?php
  107. if ($_POST['wy'] == true) {
  108.  
  109. if ($monety < $kwytrzymalosc)
  110. echo('Brak kasy');
  111. else
  112.  
  113. if ($monety > $kwytrzymalosc){
  114. $monety = $monety - $kwytrzymalosc;
  115. $wytrzymalosc= $wytrzymalosc +1;
  116.  
  117. $file45 = "user/$login/staty/wytrzymalosc.txt";
  118. $fp = fopen($file45, 'w');
  119. $dane45=$wytrzymalosc;
  120.  
  121.  flock($fp, 2);
  122.  fwrite($fp, $dane45);
  123.  flock($fp, 3);
  124.  fclose($fp);
  125.  
  126. $file45 = "user/$login/staty/monety.txt";
  127. $fp = fopen($file45, 'w');
  128. $dane41=$monety;
  129.  
  130.  flock($fp, 2);
  131.  fwrite($fp, $dane41);
  132.  flock($fp, 3);
  133.  fclose($fp);
  134.  
  135.  
  136. }
  137. }
  138. ?>
  139.  
  140. <FORM action="postac.php" method="post">
  141. <td width="80">&nbsp;Koszt :</td>
  142. <td> 
  143. <input type="text" SIZE=6 class="klasa" readonly value="<?php echo $ksila; ?>" name="T2" /></td>
  144. </tr>
  145. <tr>
  146. <td width="98">Zręcznosc </td>
  147. <td width="112"> 
  148. <input type="text" SIZE=3 class="klasa" readonly value="<?php echo $zrecznosc; ?>" name="T3" /></td>
  149. <td width="55">
  150. <input type="button" value="+1" name="zr">
  151. </form>
  152. <?php
  153. if ($_POST['zr'] == true) {
  154.  
  155.  
  156. if ($monety < $kzrecznosc)
  157. echo('Brak kasy');
  158. else
  159.  
  160. if ($monety > $kzrecznosc){
  161. $monety = $monety - $kzrecznosc;
  162. $zrecznosc = $zrecznosc +1;
  163.  
  164. $file15 = "user/$login/staty/zrecznosc.txt";
  165. $fp = fopen($file15, 'w');
  166. $dane11=$zrecznosc;
  167.  
  168.  flock($fp, 2);
  169.  fwrite($fp, $dane11);
  170.  flock($fp, 3);
  171.  fclose($fp);
  172.  
  173. $file16 = "user/$login/staty/monety.txt";
  174. $fp = fopen($file16, 'w');
  175. $dane21=$monety;
  176.  
  177.  flock($fp, 2);
  178.  fwrite($fp, $dane21);
  179.  flock($fp, 3);
  180.  fclose($fp);
  181.  
  182.  
  183. }
  184. }
  185. ?>
  186.  
  187.  
  188.  
  189. </td>
  190. <td width="80">&nbsp;Koszt :</td>
  191. <td> 
  192.  
  193.  
  194.  
  195. <FORM action="postac.php" method="post">
  196. <input type="text" SIZE=6 class="klasa" readonly value="<?php echo $kzrecznosc; ?>" name="T4" /></td>
  197. </tr>
  198. <tr>
  199. <td width="98">Zwinnosc</td>
  200. <td width="112">
  201. <input type="text" SIZE=3 class="klasa" readonly value="<?php echo $zwinnosc; ?>" name="T8" /></td>
  202. <td width="55">
  203. <input type="button" value="+1" name="zw">
  204. </form>
  205. <td width="80">&nbsp;Koszt :</td>
  206.  
  207. <?php
  208. if ($_POST['zw'] == true) {
  209.  
  210. if ($monety < $kzwinnosc)
  211. echo('Brak kasy');
  212. else
  213.  
  214. if ($monety > $kzwinnosc){
  215. $monety = $monety - $kzwinnosc;
  216. $zwinnosc = $zwinnosc +1;
  217.  
  218. $file21 = "user/$login/staty/zwinnosc.txt";
  219. $fp = fopen($file21, 'w');
  220. $dane13=$zwinnosc;
  221.  
  222.  flock($fp, 2);
  223.  fwrite($fp, $dane13);
  224.  flock($fp, 3);
  225.  fclose($fp);
  226.  
  227. $file22 = "user/$login/staty/monety.txt";
  228. $fp = fopen($file22, 'w');
  229. $dane22=$monety;
  230.  
  231.  flock($fp, 2);
  232.  fwrite($fp, $dane22);
  233.  flock($fp, 3);
  234.  fclose($fp);
  235.  
  236.  
  237. }
  238. }
  239. ?>
  240.  
  241.  
  242. <FORM action="postac.php" method="post">
  243.  
  244.  
  245.  
  246. <td> 
  247. <input type="text" SIZE=6 class="klasa" readonly value="<?php echo $kzwinnosc; ?>" name="T5" /></td>
  248. </tr>
  249. <tr>
  250. <td width="98">Inteligencja</td>
  251. <td width="112"> 
  252. <input type="text" SIZE=3 class="klasa" readonly value="<?php echo $inteligencja; ?>" name="T9" ></td>
  253. <td width="55"> 
  254. <input type="button" value="+1" name="in">
  255. </form>
  256. <?php
  257. if ($_POST['in'] == true) {
  258.  
  259. if ($monety < $kinteligencja)
  260. echo('Brak kasy');
  261. else
  262.  
  263. if ($monety > $kinteligencja){
  264. $monety = $monety - $kinteligencja;
  265. $inteligencja = $inteligencja +1;
  266.  
  267. $file25 = "user/$login/staty/inteligencja.txt";
  268. $fp = fopen($file25, 'w');
  269. $dane25=$inteligencja;
  270.  
  271.  flock($fp, 2);
  272.  fwrite($fp, $dane25);
  273.  flock($fp, 3);
  274.  fclose($fp);
  275.  
  276. $file31 = "user/$login/staty/monety.txt";
  277. $fp = fopen($file31, 'w');
  278. $dane31=$monety;
  279.  
  280.  flock($fp, 2);
  281.  fwrite($fp, $dane31);
  282.  flock($fp, 3);
  283.  fclose($fp);
  284.  
  285.  
  286. }
  287. }
  288. ?>
  289.  
  290.  
  291. <td width="80">&nbsp;Koszt :</td>
  292. <td> 
  293. <input type="text" SIZE=6 class="klasa" readonly value="<?php echo $kinteligencja; ?>" name="T6" /></td>
  294. </tr>
  295. <tr>
  296. <td width="98">Wytrzymałosc</td>
  297. <td width="112"> 
  298. <input type="text" SIZE=3 class="klasa" readonly value="<?php echo $wytrzymalosc; ?>" name="T10" ></td>
  299. <td width="55"><input type="button" value="+1" name="wy">
  300. <td width="80">&nbsp;Koszt :</td>
  301. <td> 
  302. <input type="text" SIZE=6 class="klasa" readonly value="<?php echo $kwytrzymalosc; ?>" name="T7" ></td>
  303. </tr>
  304. </table>
  305. <p align="left">
  306.  
  307. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  308. </p>
  309. <form>
  310.  
  311. <p>
  312.  
  313. <br>
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321. </p>
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329. </p>
  330. </TD>
  331. </tr>
  332. <tr>
  333. <TD width="141" height="40" nowrap>
  334. Zlotych monet : <input type="text" readonly value="<?php echo $monety; ?>" /></TD>
  335. </tr>
  336. <tr>
  337. <TD width="141" height="40" nowrap>
  338. <img src="s.jpg"><a href="postac.php">Postac</a></TD>
  339. </tr>
  340. <tr>
  341. <TD width="141" height="40" nowrap>
  342. <img src="s.jpg"><a href="ekwipunek.php">Ekwipunek</a></TD>
  343. </tr>
  344. <tr>
  345. <TD width="141" height="40" nowrap>
  346. <img src="s.jpg"><a href="polowanie.php">Polowanie</a></TD>
  347. </tr>
  348. <tr>
  349. <TD width="141" height="40" nowrap>
  350. <img src="s.jpg"><a href="sklep.php">Sklep</a></TD>
  351. </tr>
  352. <tr>
  353. <TD width="141" height="40" nowrap>
  354. <img src="s.jpg"><a href="praca.php">Praca</a></TD>
  355. </tr>
  356. <tr>
  357. <TD width="141" height="40" nowrap>
  358. <img src="s.jpg"><a href="index.html">Wyloguj</a></TD>
  359. </tr>
  360. <TR>
  361. <TD width="132" height="384">&nbsp;</TD></TR></TABLE>
  362. <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  363. </p>
  364. <p>&nbsp; </p>
  365.  
  366. </body>
  367.  
  368. </html>
  369. <?php ob_end_flush(); ?>
Go to the top of the page
+Quote Post

Posty w temacie
- robootb   [php] Problem z if_em   14.04.2007, 17:11:50
- - Łukasz O.   a może by tak tego drugiego IF'a w klamerki za...   14.04.2007, 17:45:46
- - robootb   Bardzo Dziekuej za pomoc. A mam takie pytanko czy ...   14.04.2007, 18:04:46
- - Łukasz O.   nie, ale nic nie stoi na przeszkodzie, aby dynamic...   14.04.2007, 18:10:24
- - robootb   a i jeszcze jak pod inputa podpisac kolorek tla i ...   14.04.2007, 18:22:40
- - JaRoPHP   Cytat(robootb @ 14.04.2007, 17:22:40 ...   14.04.2007, 18:28:36
- - robootb   rozumiem, ale mi teraz chodzi juz typowo o html to...   14.04.2007, 18:32:59
- - Łukasz O.   <input type='text' readonly value=...   14.04.2007, 18:40:44
- - robootb   Ok, bede sie staral bo to zrobilem.... Ale za poz...   14.04.2007, 20:54:02
- - Łukasz O.   SUBMIT!!! nie BUTTON   14.04.2007, 23:47:12
- - robootb   Dalej nie dziala ...   15.04.2007, 06:38:37
- - Łukasz O.   to zbadaj czemu:/ daj całą tą swoją tabelę wewnątr...   15.04.2007, 07:50:17
- - robootb   Proboje ale nic nie wychodzi. Jak bym umial to bym...   15.04.2007, 08:03:36
- - JaRoPHP   Cytat(robootb @ 15.04.2007, 07:03:36 ...   15.04.2007, 09:22:56
- - robootb   [PHP] pobierz, plaintext <?php ob_start(...   15.04.2007, 10:12:45
- - Łukasz O.   jakiś nie kumaty jesteś czy jak? przecież powiedzi...   15.04.2007, 12:20:21
- - robootb   Ja nie chce nikomu udowadniac kim ja jestem i co j...   15.04.2007, 12:37:29
- - Łukasz O.   będziesz miał błędy, bo nawet nie przekazujesz zmi...   15.04.2007, 13:08:29
- - klekot   Nie mozna odnalezc pliku postac.php   15.04.2007, 13:57:38
- - Łukasz O.   kolega chyba kompa wyłączył jako bonus: [PHP] pob...   15.04.2007, 14:10:07


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

 



RSS Aktualny czas: 26.12.2025 - 05:16