Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][PHP]Formularz PHP(form2mail) dodanie treści
patys
post 2.07.2011, 21:14:38
Post #1





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 11.08.2009

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


Siema,

Na swojej stronie mam formularz php wysyłający emaile(form2mail), dodałem różne zmienne i teraz mam problem, aby dodać te zmienne do wysyłanej wiadomości.

  1. <table width="239" cellpadding="0" cellspacing="0"><form action="inc/email/Form2Mail1.php">
  2.  
  3. <input type=hidden name=Subject value="Testing Form2Mail1.php">
  4. <br>
  5. <tr>
  6. <td class="first">
  7. Data przyjazdu<br />
  8. <select name="FirstName">
  9. <option>Styczeń</option>
  10. <option>Luty</option>
  11. <option>Marzec</option>
  12. <option>Kwiecień</option>
  13. <option>Maj</option>
  14. <option>Czerwiec</option>
  15. <option>Lipiec</option>
  16. <option>Sierpień</option>
  17. <option>Wrzesień</option>
  18. <option>Październik</option>
  19. <option>Listopad</option>
  20. <option>Grudzień</option>
  21. </select>
  22. </td>
  23. <td class="second"><br />
  24. Rok<br>
  25. <select name="LastName" class="year">
  26. <option>2011</option>
  27. <option>2012</option>
  28. <option>2013</option>
  29. </select></td>
  30. <td class="second"><br />
  31. Data<br />
  32. <select name="From" class="date">
  33. <option>1</option>
  34. <option>2</option>
  35. <option>3</option>
  36. <option>4</option>
  37. <option>5</option>
  38. <option>6</option>
  39. <option>7</option>
  40. <option>8</option>
  41. <option>9</option>
  42. <option>10</option>
  43. <option>11</option>
  44. <option>12</option>
  45. <option>13</option>
  46. <option>14</option>
  47. <option>15</option>
  48. <option>16</option>
  49. <option>17</option>
  50. <option>18</option>
  51. <option>19</option>
  52. <option>20</option>
  53. <option>21</option>
  54. <option>22</option>
  55. <option>23</option>
  56. <option>24</option>
  57. <option>25</option>
  58. <option>26</option>
  59. <option>27</option>
  60. <option>28</option>
  61. <option>29</option>
  62. <option>30</option>
  63. <option>31</option>
  64. </select>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td class="first">
  69. Ilość nocy<br />
  70. <select name="noce">
  71. <option>1</option>
  72. <option>2</option>
  73. <option>3</option>
  74. <option>4</option>
  75. <option>5</option>
  76. <option>6</option>
  77. <option>7</option>
  78. <option>8</option>
  79. <option>9</option>
  80. <option>10</option>
  81. <option>11</option>
  82. <option>12</option>
  83. <option>13</option>
  84. <option>14</option>
  85. <option>15</option>
  86. <option>16</option>
  87. <option>17</option>
  88. <option>18</option>
  89. <option>19</option>
  90. <option>20</option>
  91. <option>21</option>
  92. <option>22</option>
  93. <option>23</option>
  94. <option>24</option>
  95. <option>25</option>
  96. <option>26</option>
  97. <option>27</option>
  98. <option>28</option>
  99. <option>29</option>
  100. <option>30</option>
  101. <option>31</option>
  102. <option>Więcej</option>
  103. </select>
  104. </td>
  105. <td class="third">
  106. Ilość pokoi<br />
  107. <select name="pokoje">
  108. <option>1</option>
  109. <option>2</option>
  110. <option>3</option>
  111. <option>4</option>
  112. <option>Więcej</option>
  113.  
  114. </select>
  115. </td>
  116. </tr>
  117. <tr>
  118. <td class="first">
  119. Ilość dorosłych<br />
  120. <select name="dorosli">
  121. <option>1</option>
  122. <option>2</option>
  123. <option>3</option>
  124. <option>4</option>
  125. <option>5</option>
  126. <option>Więcej</option>
  127.  
  128. </select>
  129. </td>
  130. <td class="third">
  131. Ilość dzieci<br />
  132. <select name="dzieci">
  133. <option>1</option>
  134. <option>2</option>
  135. <option>3</option>
  136. <option>4</option>
  137. <option>5</option>
  138. <option>Więcej</option>
  139. </select>
  140. </td>
  141. </tr>
  142. <tr>
  143. <td colspan="2" class="reset"><a href="#">Resetuj</a></td>
  144. </tr>
  145. </table>


form2mail.php


  1. <?
  2. /*
  3.  
  4.   General Form2Mail script that will send an email using PHP's standard
  5.   "mail()" function. The script will take all the form variables
  6.   and stuff them in an email. You can define the following special
  7.   variables in the form:
  8.  
  9.   From The emailaddress to send the email from.
  10.   Subject The subject of the email.
  11.  
  12.   WARNING: do not change this script to accept a "to" address from the
  13.   form. It could then be abused by spammers. Keep the "to" address
  14.   hardcoded in this script, see below.
  15.  
  16. */
  17.  
  18.  
  19. /* Change these settings. */
  20. $To = '...'; /* To send the email to. */
  21. $SmtpServer = 'smtp.yourdomain.com'; /* The mailserver to use. */
  22. $NextPage = 'success.html'; /* To jump to after sending. */
  23. $tresc = include('tresc.html';
  24.  
  25.  
  26.  
  27.  
  28.  
  29. /* Compose the email. */
  30. if (isset($HTTP_GET_VARS)) {
  31. while ($a = each($HTTP_GET_VARS)) {
  32. if ($a[0] == 'From') continue;
  33. if ($a[0] == 'Subject') continue;
  34. if ($a[0] == 'Submit') continue;
  35. $Body .= $a[0] . "\t= " . $a[1] . "\r\n";
  36. }
  37. }
  38. if (isset($HTTP_POST_VARS)) {
  39. while ($a = each($HTTP_POST_VARS)) {
  40. if ($a[0] == 'From') continue;
  41. if ($a[0] == 'Subject') continue;
  42. if ($a[0] == 'Submit') continue;
  43. $Body .= $a[0] . "\t= " . $a[1] . "\r\n";
  44. }
  45. }
  46.  
  47.  
  48.  
  49. /* Remove dangerous characters. */
  50. $Subject = ereg_replace("[^-[:alnum:]_.!@=* ]","",$Subject);
  51. $From = ereg_replace("[^-[:alnum:]_.!@=* ]","",$From);
  52.  
  53.  
  54.  
  55. /* Send the email. */
  56. ini_set("SMTP",$SmtpServer);
  57. ini_set("sendmail_from",$From);
  58. $Status = mail($To,$Subject,$Body+$tresc);
  59. if ($Status != TRUE) {
  60. echo '<html><body>' . "\n";
  61. echo '<b>An error has occurred while sending the email.' . "\n";
  62. echo '</body></html>' . "\n";
  63. }
  64.  
  65.  
  66.  
  67.  
  68. /* Jump to the NextPage. */
  69. header('location: ' . $NextPage);
  70. ?>



Jest zmienna $body, ale nie wiem skąd brane są zmienne /t i inne. Zmienne "firstname" i "lastname" są normalnie pobierane z selectów. Chciałbym aby reszta tez była pobierana.

Co i jak musiałbym zrobić?

Z góry dziękuję i pozdrawiam smile.gif
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 Wersja Lo-Fi Aktualny czas: 13.08.2025 - 22:52