Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Formularz zgłoszeniowy, nie przesyła/pobiera danych
kafar610
post
Post #1





Grupa: Zarejestrowani
Postów: 51
Pomógł: 0
Dołączył: 13.01.2013
Skąd: Pruszków

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


Witam
Mam problem z moim małym skrypcikiem bo nie pobiera mi niektorych danych, bierze tylko numer telefonu i email, i nie wiem czemu.
Prosze o wyrozumiałość gdyż jestem świeżakiem (IMG:style_emoticons/default/biggrin.gif)
  1. <?php
  2.  
  3. $email_to = "kafar610@gmail.com";
  4. $email_subject = "Your email subject line";
  5.  
  6. $first_name = $_POST['firstname'];
  7. $last_name = $_POST['lastname'];
  8. $email = $_POST['email'];
  9. $telephone = $_POST['telephone'];
  10. $other = $_POST['other'];
  11.  
  12. $msg = "Imię: $firstname\n" .
  13. "Nazwisko: $last_name\n" .
  14. "email: $email\n" .
  15. "telephone: $telephone\n" .
  16. "Inne komentarze: $other";
  17.  
  18. $headers = 'From: ' . $_POST['email'] . "\r\n" .
  19. 'Content-type: text/html; charset=utf-8';
  20.  
  21. mail($email_to, $email_subject, $msg, $headers);
  22. echo 'Wszystko ok';
  23.  
  24. ?>


  1. <form name="contactform" method="post" action="report.php">
  2.  
  3. <table width="750px" cellspacing="10">
  4.  
  5. <tr>
  6.  
  7. <td valign="top">
  8.  
  9. <label for="firstname">Imię: *</label>
  10.  
  11. </td>
  12.  
  13. <td valign="top">
  14.  
  15. <input type="text" id="firstname" name="firstname" />
  16.  
  17. </td>
  18.  
  19. </tr>
  20.  
  21. <tr>
  22.  
  23. <td valign="top">
  24.  
  25. <label for="last_name">Nazwisko *</label>
  26.  
  27. </td>
  28.  
  29. <td valign="top">
  30.  
  31. <input type="text" name="last_name" maxlength="50" size="30">
  32.  
  33. </td>
  34.  
  35. </tr>
  36.  
  37. <tr>
  38.  
  39. <td valign="top">
  40.  
  41. <label for="email">Adres e-mail *</label>
  42.  
  43. </td>
  44.  
  45. <td valign="top">
  46.  
  47. <input type="text" name="email" maxlength="80" size="30">
  48.  
  49. </td>
  50.  
  51. </tr>
  52.  
  53. <tr>
  54.  
  55. <td valign="top">
  56.  
  57. <label for="telephone">Numer telefonu</label>
  58.  
  59. </td>
  60.  
  61. <td valign="top">
  62.  
  63. <input type="text" name="telephone" maxlength="30" size="30">
  64.  
  65. </td>
  66.  
  67. </tr>
  68.  
  69. <tr>
  70.  
  71. <td valign="top">
  72.  
  73. <label for="other">Pytania, uwagi *</label>
  74.  
  75. </td>
  76.  
  77. <td valign="top">
  78.  
  79. <textarea name="msg" maxlength="1000" cols="25" rows="6"></textarea>
  80.  
  81. </td>
  82.  
  83. </tr>
  84.  
  85. <tr>
  86.  
  87. <td colspan="2" style="text-align:center">
  88.  
  89. <input type="submit" value="Submit">
  90.  
  91. </td>
  92.  
  93. </tr>
  94.  
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kafar610
post
Post #2





Grupa: Zarejestrowani
Postów: 51
Pomógł: 0
Dołączył: 13.01.2013
Skąd: Pruszków

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


dobra już poprawiłem wszystko, lecz zacząłem rozszerzać swój skrypcik i natrafiłem na kolejne problemy ...
nie zachowuje wprowadzonych danych, nie wysyła emaila, nie działa walidacja :/

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Zrób ze mnie Elvisa - Wysyłanie wiadomości</title>
  7. </head>
  8. <body>
  9.  
  10. <?php
  11. if (isset($_POST['submit'])) { // sprawdza wartosc zmiennej submit, jesli user nie przeslal formularza to zmienna ta nie bedzie ustawiona
  12. $email_to = "kafar610@gmail.com";
  13. $email_subject = "Your email subject line";
  14. $output_form = false; //jesli false to nie wyswietlamy
  15.  
  16. $nick = $_POST['nick'];
  17. $email = $_POST['email'];
  18. $telephone = $_POST['telephone'];
  19. $other = $_POST['other'];
  20.  
  21. if (empty($nick) && empty($email) && empty($other)) {
  22. echo 'Uzupełnij wszystkie pola<br />';
  23. $output_form = true; // jesli true to wyswietlamy formularz
  24. }
  25.  
  26. if (empty($nick) && (!empty($email)) && (!empty($other))) {
  27. echo 'Nie podałeś imienia i nazwiska.<br />';
  28. $output_form = true;
  29. }
  30.  
  31. if ((!empty($nick)) && empty($email) && (!empty($other))) {
  32. echo 'Nie podałeś emaila<br />';
  33. $output_form = true;
  34. }
  35.  
  36. if ((!empty($nick)) && (!empty($email)) && empty($other)) {
  37. echo 'Nie zadałeś pytania<br />';
  38. $output_form = true;
  39. }
  40.  
  41. }
  42.  
  43. else{
  44. $output_form = true; // jesli skrypt nie udospetnil formularza to koniecznie trrzeba to zrobic zmienna $isset
  45. }
  46.  
  47.  
  48. if ((!empty($nick)) && (!empty($email)) && (!empty($other))) {
  49.  
  50. $msg = "Imię i nazwisko: $name\n" .
  51. "email: $email\n" .
  52. "telephone: $telephone\n" .
  53. "Inne komentarze: $other";
  54.  
  55. $headers = 'From: ' . $_POST['email'] . "\r\n" .
  56. 'Content-type: text/html; charset=utf-8';
  57.  
  58. mail($email_to, $email_subject, $msg, $headers);
  59. echo 'Wszystko ok';
  60. }
  61.  
  62. if ($output_form) { // sprawdza wartosc zmiennej $output_form jesli true to wyswietla formularz
  63. ?>
  64.  
  65. <form name="contactform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  66. <table width="750px" cellspacing="10">
  67. <tr>
  68. <td valign="top">
  69. <label for="nick">Imię i nazwisko *</label>
  70. </td>
  71. <td valign="top">
  72. <input type="text" name="nick" maxlength="50" value="<?php echo $name; ?>" size="30">
  73. </td>
  74. </tr>
  75. <tr>
  76. <td valign="top">
  77. <label for="email">Adres e-mail *</label>
  78. </td>
  79. <td valign="top">
  80. <input type="text" name="email" maxlength="80" value="<?php echo $email; ?>" size="30">
  81. </td>
  82. </tr>
  83. <tr>
  84. <td valign="top">
  85. <label for="telephone">Numer telefonu</label>
  86. </td>
  87. <td valign="top">
  88. <input type="text" name="telephone" maxlength="30" value="<?php echo $telephone; ?>" size="30">
  89. </td>
  90. </tr>
  91. <tr>
  92. <td valign="top">
  93. <label for="other">Pytania, uwagi *</label>
  94. </td>
  95. <td valign="top">
  96. <textarea name="other" maxlength="1000" cols="25" rows="6"><?php echo $other; ?></textarea>
  97. </td>
  98. </tr>
  99. <tr>
  100. <td colspan="2" style="text-align:center">
  101. <input type="submit" value="Submit">
  102. </td>
  103. </tr>
  104. </table>
  105. </form>
  106.  
  107. <?php
  108. }
  109.  
  110. ?>
  111.  
  112. </body>
  113. </html>
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 16.10.2025 - 22:21