Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Zasięg zmiennych, tablice superglobalne..., Nie printuje w funkcji!
Tilosag
post
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 10.04.2007

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


Bardzo dziwne! Zmienna roznicax jest umieszczina w tablicy superglobalnej $_POST , a program jej nie printuje, dlaczego?questionmark.gif

spawn.php \/
  1. <?php
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
  6. <meta http-equiv="Creation-date" content="2007-04-10T18:55:03Z">
  7. <meta name="Authoring-tool" content="Pajaczek NxG PRO v5.6.1">
  8. </head>
  9.  
  10. <body>
  11.  
  12. <form enctype="multipart/form-data" action="code.php" method="POST">
  13.  
  14. <table border="1">
  15. <tr>
  16. <td>
  17.  
  18. <!-- MAX_FILE_SIZE must precede the file input field -->
  19.  
  20. <!-- Name of input element determines name in $_FILES array -->
  21. Plik: <input name="plik" type="file" />
  22.  
  23.  
  24.  
  25. </td>
  26. </tr>
  27. <tr>
  28. <td>Potworek by&#322; na pozycji:</td>
  29. <td>Potworek jest na pozycji:</td>
  30. </tr>
  31. <tr>
  32. <td>X
  33. <input type="text" name="x1" value="" /></td>
  34. <td>X
  35. <input type="text" name="x2" value="" /></td>
  36. </tr>
  37. <tr>
  38. <td>Y
  39. <input type="text" name="y1" value="" /></td>
  40. <td>Y
  41. <input type="text" name="y2" value="" /></td>
  42. </tr>
  43. <tr>
  44. <td>Z
  45. <input type="text" name="z1" value="" /></td>
  46. <td>Z
  47. <input type="text" name="z2" value="" /></td>
  48. </tr>
  49. </table>
  50.  
  51. <table width="100$" height="100%">
  52. <tr>
  53. <td align="center" valign="middle" width="300px">
  54. <input type="submit" name="submit" value="Wykonaj" /></td>
  55. </tr>
  56. </table>
  57.  
  58. </form>
  59.  
  60. </body>
  61. </html>
  62. ?>


code.php \/

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
  5. <meta http-equiv="Creation-date" content="2007-04-12T13:02:48Z">
  6. <meta name="Authoring-tool" content="Pajaczek NxG PRO v5.6.1">
  7. <title></title>
  8. </head>
  9.  
  10. <body>
  11. <?php
  12. ini_set ('display_errors', 1);
  13.  
  14.  
  15. $_POST['roznicax']=$_POST['x2']-$_POST['x1'];
  16. $_POST['roznicay']=$_POST['y2']-$_POST['y1'];
  17. $_POST['roznicaz']=$_POST['z2']-$_POST['z1'];
  18.  
  19. print('Roznica X:'. $_POST['roznicax']);
  20. print('<br />');
  21. print('Roznica Y:'. $_POST['roznicay']);
  22. print('<br />');
  23. print('Roznica Z:'. $_POST['roznicaz']);
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. $uploaddir = '/Program Files/WebServ/httpd/spawn/XML/';
  31. $uploadfile = $uploaddir . basename($_FILES['plik']['name']);
  32.  
  33. echo '<pre>';
  34. if (move_uploaded_file($_FILES['plik']['tmp_name'], $uploadfile)) {
  35. echo "Pierwszy stpień obliczeń - DONE!";
  36. } else {
  37. echo "Possible file upload attack!";
  38. }
  39. print "</pre>";
  40.  
  41. $fd=fopen($uploadfile,"r+");
  42. $fstring = fread($fd , filesize($uploadfile));
  43.  
  44.  
  45. function addToX($matches) //credits to nospor
  46. {
  47. print $_POST['roznicax']; // w TYM miejscu nie printuje!!!
  48. return 'x="'.($matches[1]+$_POST['roznicax']).'"';
  49. }
  50.  
  51. $text = "$fstring";
  52. $search = '/x="(d+)"/';
  53. $replace = preg_replace_callback($search,"addToX",$text);
  54. $fout=fwrite($fd, $replace);
  55.  
  56. ?>
  57. </body>
  58. </html>



POMOCY!

Ten post edytował Tilosag 12.04.2007, 15:02:29
Go to the top of the page
+Quote Post

Posty w temacie


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: 22.08.2025 - 04:51