Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Formularz zamówienia, Problem z pobieraniem danych z pola text
Maveric.pl
post
Post #1





Grupa: Zarejestrowani
Postów: 10
Pomógł: 0
Dołączył: 17.05.2007
Skąd: Koło

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


Witajcie.

Mam problem, z którym nie mogę sobie poradzić. Szukałem i nie znalazłem odpowiedzi.
Możliwe że coś pominąłem więc jeśli się powiela problem przepraszam.

Muszę zrobić formularz zamówienia, gdzie z bazy będzie pobierana lista produktów, przy każdym z nich pole text do wpisania ilości sztuk.
Formularz pobiera dane, przesyła zaznaczone pola, ale pojęcia nie mam jak podpiąć pole textowe.
Formularz ma wysłać na maila określone zamówienie do zdefiniowanej osoby.

  1. <?php
  2. include('dbdef.php.inc');
  3. include('logintest.php');
  4. if (count($_POST))
  5. {
  6. ////////// USTAWIENIA //////////
  7. $email = 'mail@domena.pl'; // Adres e-mail adresata
  8. $subject = 'temat'; // Temat listu
  9. $message = "Dziękujemy za wysłanie formularza<br><a href='mailsender.php'>Powrot</a>"; // Komunikat
  10. $error = 'Wystąpił błąd podczas wysyłania formularza'; // Komunikat błędu
  11. $charset = 'iso-8859-2'; // Strona kodowa
  12. //////////////////////////////
  13. $head =
  14. "MIME-Version: 1.0\r\n" .
  15. "Content-Type: text/plain; charset=$charset\r\n" .
  16. "Content-Transfer-Encoding: 8bit";
  17. $body = '';
  18. foreach ($_POST as $value)
  19. {
  20. if (is_array($value))
  21. {
  22. for ($i = 0; $i < count($value); $i++)
  23. {
  24. $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value[$i]) : $value[$i]) . "\r\n";
  25. }
  26. }
  27. else $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value) : $value) . "\r\n";
  28. }
  29. echo mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head) ? $message : $error;
  30. }
  31. else
  32. {
  33. ?>
  34.  
  35. <form action="?" method="post">
  36.  
  37. <?php
  38.  
  39. $query = @mysql_query('SELECT toners_list.id, producers.prod_name as producent, toners_list.model, toners_list.color FROM toners_list, producers WHERE producers.id=toners_list.prod_id ORDER BY toners_list.id ASC');
  40.  
  41. if (!$query) {
  42. exit('<p>Problem podczas pobierania danych!<br />'.
  43. 'Error: ' . mysql_error() . '</p>');
  44. }
  45.  
  46. echo ("<table cellspacing=1 cellpadding=0><tbody>");
  47. echo ("<tr style='background-color: rgb(232,232,232);'>
  48. <td style='width: 45px;'></td>
  49. <td style='width: 120px;'><p class='data_table_title'>Producent</p></td>
  50. <td style='width: 90px;'><p class='data_table_title'>Model</p></td>
  51. <td style='width: 90px;'><p class='data_table_title'>Kolor</p></td>
  52. <td style='width: 90px;'><p class='data_table_title'>Sztuk</p></td>
  53. </tr>");
  54.  
  55. while ($tdata = mysql_fetch_array($query)) {
  56.  
  57. $id = $tdata['id'];
  58. $tproducent = $tdata['producent'];
  59. $tmodel = htmlspecialchars($tdata['model']);
  60. $tkolor = $tdata['color'];
  61.  
  62.  
  63. echo ("<tr>
  64. <td><input type='checkbox' name='' value='$tmodel, $tproducent, $tkolor' /></td>
  65. <td>$tproducent</td>
  66. <td>$tmodel</td>
  67. <td>$tkolor</td>
  68. <td><input type='text' name='ilosc' size='2' maxlength='3' /></td>
  69. </tr>");
  70.  
  71. }
  72. echo ('</tbody></table>');
  73. ?><input type="submit" value="Zamow!" />
  74.  
  75. </form>
  76. <?php
  77. }
  78. ?>


Pomóżcie proszę jak to dopiąć.
Go to the top of the page
+Quote Post

Posty w temacie


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: 4.10.2025 - 16:56