Borykam siê z problemem - mianowicie - napisa³em progrogram do obs³ugi firmy - faktury juz ³adnie dzia³aj±, magazyn równie¿ ale tutaj pojawia sie problem

Chodzi o dwa pliki - wybór produktu na pz, oraz dodanie go do pz ( lub wz, nie ma znaczenia)

Pytanie moje jest takie jak ograniczyæ tak± sytacje - u¿ytkownik wybiera produkt wpisuje ilosc itd - przechodzi do dodaj_do_pz.php ... produkt jest wpisywany i ok , ale co je¶li teraz da wstecz na przegladarce..
mo¿e problem tkwi w tym jak to napisalem, wklejam kod :

To jest akurat do edycji bo z tym mia³em problem

wybierz_produkt_edycja_wz.php :

  1.  
  2.  
  3.  
  4. $db = mysql_pconnect("localhost", "root", "****");
  5. mysql_select_db("jakar"); 
  6. if (!$db) {  
  7. print "wyst±pi³ b³±d w po³±czeniu";  
  8. exit;
  9. }
  10. function ShowSel() {
  11. $result = mysql_query("select nazwa from produkty order by nazwa asc");
  12. while($dane = mysql_fetch_array($result)){
  13.  echo '<option value="'.$dane[0].'">'.$dane[0].'</option>';
  14.  
  15.  }
  16.  
  17. }
  18.  
  19.  
  20.  
  21.  
  22.  
  23. if(isset($_POST["hid"]) && !empty($_POST["hid"]) && $_POST["hid"]!="--") {
  24. $res = mysql_query("select * from magazyn_biezacy_polgames where nazwa='".$_POST["s"]."'");
  25.  
  26. $dane = mysql_fetch_row($res);
  27.  
  28. } else {
  29. $dane = array_fill(0,13," ");
  30.  
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37. $_SESSION['nazwa'] = $dane[0];
  38.  
  39. ?>
  40. <title>Dodaj produkt</title><body bgcolor="#efefefe" text="#000000" leftmargin="0" topmargin="0" vlink="#000000" alink="#000000">
  41. <STYLE TYPE="TEXT/CSS"><!--
  42. A:link {
  43. color:#000000;
  44.  
  45. font-family:verdana;
  46. font-style:normal;
  47. font-weight:normal;
  48. text-decoration:none;
  49. cursor:hand;
  50. }
  51. A:visited {
  52. color:#000000;
  53.  
  54. font-family:verdana;
  55. font-style:normal;
  56. font-weight:normal;
  57. text-decoration:none;
  58. cursor:hand;
  59. }
  60.  
  61. A:hover {
  62. color:#000000;
  63. font-family:verdana;
  64. font-style:normal;
  65. font-weight:bold;
  66. text-decoration:underline;
  67. cursor:hand;
  68. }
  69. //--></STYLE>
  70. <form action="wybierz_produkt_edycja_wz.php " method="post">
  71.  
  72. <table height="15" width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#efefefef" bgcolor="#000000">
  73. <tr> 
  74. <td> 
  75. <div align="left"><b><font size="2" color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">System
  76. obs³ugi firmy JAKAR</font></b></div>
  77. </td>
  78. <td><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="1">|
  79. ver. 1.0 | wykonanie : Leonard Pociask |</font></td>
  80. </tr>
  81. </table>
  82.  
  83.  
  84. <table height="10" width="10%" border="0" cellspacing="0" cellpadding="0" align="left">
  85.  <tr>
  86.  <td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
  87. | <a href="../index.php">G³ówna</a> </font>
  88. </td>
  89.  </tr>
  90. </table>
  91. <table height="10" width="20%" border="0" cellspacing="0" cellpadding="0" align="left" bordercolor="#000000">
  92. <tr>
  93.  <td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
  94. | <a href="poczatek.php">Magazyn towarów</a> </font>
  95. </td>
  96. </tr>
  97.  
  98. </table>
  99. <table height="10" width="23%" border="0" cellspacing="0" cellpadding="0" align="left">
  100. <tr>
  101. <td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif"> 
  102. | Dodaj produkt</font></td>
  103. </tr>
  104.  
  105. </table>
  106. <br>
  107.  
  108. <table width="100%" border="1" align="center" bordercolor="#efefef" cellspacing="0" cellpadding="0">
  109. <tr>
  110. <td bgcolor="#990000">
  111. <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CCCCCC">Dodaj 
  112. produkt do dokumentu WZ 
  113. <? echo $_SESSION['id'];?>
  114. </font></div>
  115. </td>
  116. </tr>
  117. </table>
  118. <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><font size="1">
  119.  
  120. </font></b></font></p>
  121. <table width="52%" border="1" align="center" height="181" bordercolor="#666666">
  122. <tr> 
  123. <td height="28" bgcolor="#CCCCCC" colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><font size="1">Wybierz 
  124. produkt :</font></b></font></td>
  125. </tr>
  126. <tr> 
  127. <td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">| 
  128. Wybierz&nbsp;:</font> <font color="#000000"> </font></td>
  129. <td width="62%"><font color="#000000"> 
  130. <select id="s" name="s" onChange="document.getElementById('hid').value='submit';this.form.submit()">
  131. <option value="--">--</option>
  132. <?php ShowSel(); ?>
  133. </select>
  134. <input id="hid" name="hid" type="hidden" value="<?$_POST["s"]?>" />
  135.  
  136. </font></font></td>
  137. </tr>
  138. <tr> 
  139. <td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">| 
  140. Produkt :</font></td>
  141. <td width="62%"> 
  142. <?php echo $dane[0]; ?>
  143. </td>
  144. </tr>
  145. <tr> 
  146. <td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">| 
  147. Zapas: magazyn biezacy :</font></td>
  148. <td width="62%"> 
  149. <?php echo $dane[1]; ?>
  150. </td>
  151. </tr>
  152.  <tr>
  153. <td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">| 
  154. Ostatnie przyjecie :</font></td>
  155. <td width="62%"> 
  156. <?php echo $dane[2]; ?>
  157. </td>
  158. </tr>
  159. </tr>
  160. <tr>
  161. <td width="38%" height="24"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">| 
  162. Ilosc:</font></td>
  163. <td width="62%" height="24"> 
  164. <input type="text" id="ilosc" name="t13" value="0" />
  165. </td>
  166. </tr>
  167.  
  168. <tr> 
  169. <td colspan="2" height="53">
  170. <center>
  171. <font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><a href="java script:przeladuj()" id="przeladuj">utwórz 
  172. dokument</a> </font>
  173. </center>
  174. <script language="javascript">
  175. function przeladuj(){
  176. location = 'dodaj_produkt_wz_edycja.php?ilosc='+document.getElementById('ilosc').value;
  177. }
  178. </script>
  179. </tr>
  180. </table>
  181.  
  182.  
  183. </form>
  184. </body>
  185. </html>


Tutaj po wyborze produktu strona sie prze³adowywuje i wy¶wietla informacje o prod - mia³em problem z przekazaniem wybranych wartosci do dodaj_produkt_edycja_wz

Ponizej wkleje kod 2 pliku

Problem w tym ¿e poprostu sci±ga mi produkt z magazynu z zapasu - a wcale nie ma go tyle na wydaniach jak robie zestawienie :/


dodaj_produkt_wz_edycja.php

  1.  
  2. $nrwz = $_SESSION['id'];
  3.  
  4.  
  5. $db = mysql_pconnect("localhost", "root", "karate4kyu");
  6. mysql_select_db("jakar"); 
  7. if (!$db) {  
  8. print "wyst±pi³ b³±d w po³±czeniu";  
  9. exit;
  10. }
  11. $nazwa=$_SESSION['nazwa'];
  12. $ilosc=($_GET['ilosc']);
  13. $magazyn= "biezacy";
  14. $data=date("y-m-d");
  15.  
  16.  
  17.  
  18.  
  19. if ($magazyn == "biezacy") {
  20.  $wpis= 'magazyn_biezacy_polgames';
  21.  
  22. } else {
  23.  $wpis = 'magazyn_serwis';
  24. }
  25.  
  26. $res = mysql_query("select zapas from $wpis where nazwa='$nazwa' ") ;
  27.  
  28. while ($row = mysql_fetch_array($res, MYSQL_NUM)) {
  29.  
  30.  $aktualny_zapas= $row[0];
  31. }
  32.  
  33.  
  34.  
  35. if ($aktualny_zapas<$ilosc-1) {
  36. print "Zapas '".$nazwa."' jest mniejszy ni¿ proponowana ilosc do wydania - brak towaru na magazynie";
  37. echo '<br>';
  38. echo ' <center><input type="button" value="Powrot" onclick="history.back();"></center> ';
  39. }
  40. if(($ilosc) == 0 && ($ilosc) == 0.0)
  41.  
  42.  {
  43.  echo'<center><b>';
  44. echo '<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CCCCCC"> Nie zosta³y wype³nione obowiazkowe pola';
  45. echo ' <br>';
  46.  echo ' <br>';
  47. echo '<center><input type="button" value="Powrot" onclick="history.back();"></center>';
  48.  }
  49.  
  50. $result = mysql_query( "insert into wz_towar_polgames values ('".$nrwz."', '".$nazwa."', '".$ilosc."')")or die(mysql_error());
  51.  
  52. $result = mysql_query( "UPDATE $wpis SET zapas=zapas - $ilosc, ost_data='".$data."' where nazwa= '".$nazwa."' ")or die(mysql_error());
  53.  
  54. ?>
  55.  
  56. <title>Produkt dodany</title><body bgcolor="#efefefe" text="#000000" leftmargin="0" topmargin="0" vlink="#000000" alink="#000000">
  57. <STYLE TYPE="TEXT/CSS"><!--
  58. A:link {
  59. color:#000000;
  60.  
  61. font-family:verdana;
  62. font-style:normal;
  63. font-weight:normal;
  64. text-decoration:none;
  65. cursor:hand;
  66. }
  67. A:visited {
  68. color:#000000;
  69.  
  70. font-family:verdana;
  71. font-style:normal;
  72. font-weight:normal;
  73. text-decoration:none;
  74. cursor:hand;
  75. }
  76.  
  77. A:hover {
  78. color:#000000;
  79. font-family:verdana;
  80. font-style:normal;
  81. font-weight:bold;
  82. text-decoration:underline;
  83. cursor:hand;
  84. }
  85. //--></STYLE>
  86. <table height="15" width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#efefefef" bgcolor="#000000">
  87. <tr> 
  88. <td> 
  89. <div align="left"><b><font size="2" color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">System
  90. obs³ugi firmy JAKAR</font></b></div>
  91. </td>
  92. <td><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="1">|
  93. ver. 1.0 | wykonanie : Leonard Pociask |</font></td>
  94. </tr>
  95. </table>
  96.  
  97.  
  98. <table height="10" width="10%" border="0" cellspacing="0" cellpadding="0" align="left">
  99.  <tr>
  100.  <td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
  101. | <a href="../index.php">G³ówna</a> </font>
  102. </td>
  103.  </tr>
  104. </table>
  105. <table height="10" width="20%" border="0" cellspacing="0" cellpadding="0" align="left" bordercolor="#000000">
  106. <tr>
  107.  <td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
  108. | <a href="poczatek.php">Zestawienie faktur</a> </font>
  109. </td>
  110. </tr>
  111.  
  112. </table>
  113. <table height="10" width="26%" border="0" cellspacing="0" cellpadding="0" align="left">
  114. <tr>
  115. <td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif"> 
  116. | Dodaj produkt</font> </td>
  117. </tr>
  118.  
  119. </table>
  120. <br>
  121.  
  122. <table width="100%" border="1" align="center" bordercolor="#efefef" cellspacing="0" cellpadding="0">
  123. <tr>
  124. <td bgcolor="#990000">
  125.  
  126. <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CCCCCC">Dodano 
  127. <? $nazwa?> </font><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CCCCCC"> 
  128. do dokumentu WZ <? echo $nrwz; ?>
  129. </font></div>
  130. </td>
  131. </tr>
  132. </table>
  133. <br>
  134. <table width="20%" border="1" align="center" cellspacing="0" cellpadding="0" bordercolor="#999999" height="47">
  135. <tr> 
  136. <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">-&gt; <a href="wybierz_produkt_edycja_wz.php">dodaj
  137. kolejny produkt</a></font></td>
  138. </tr>
  139. <tr>
  140. <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">-&gt; <a href="utworzona_wz_gotowa_podglad2.php">podglad</a></font></td>
  141. </tr>
  142. <tr>
  143. <td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">-&gt; <a href="poczatek_wz.php">zakoncz</a></font></td>
  144. </tr>
  145. </table>
  146. <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><font size="1"> 
  147. </font></b></font></p>
  148.  
  149. </body>
  150. </html>