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%)
-----


testowałem, zmienne przybierają wartości, walidacja działa, e-maile wysyła lecz po dodaniu funkcji isset wszystko się chrzani, nie działa nic... formularz się wyświetla ale nic poza tym

  1. <?php
  2. if (isset($_POST['submit'])) {
  3. $output_form = false;
  4. $email_to = "kafar610@gmail.com";
  5. $email_subject = "Your email subject line";
  6.  
  7. $nick = $_POST['nick'];
  8. $email = $_POST['email'];
  9. $telephone = $_POST['telephone'];
  10. $other = $_POST['other'];
  11.  
  12.  
  13.  
  14. if (empty($nick)) {
  15. echo 'nie podałeś imienia i nazwiska<br />';
  16. $output_form = true;
  17. }
  18.  
  19. if (empty($email)) {
  20. echo 'nie podałeś emaila<br />';
  21. $output_form = true;
  22. }
  23.  
  24. if (empty($other)) {
  25. echo 'nie zadałeś pytania<br />';
  26. $output_form = true;
  27. }
  28. }
  29.  
  30. if ((!empty($nick)) && (!empty($email)) && (!empty($other))) {
  31.  
  32. $msg = "Imię i nazwisko: $nick\n" .
  33. "Telefon: $telephone\n" .
  34. "Pytania, uwagi: $other";
  35. mail($email_to, $email_subject, $msg, 'From:' . $email);
  36. echo 'Wysłano e-mail, dziękujemy <br />';
  37. }
  38.  
  39. else{
  40. $output_form = true;
  41. }
  42.  
  43. if ($output_form) { // sprawdza wartosc zmiennej $output_form jesli true to wyswietla formularz
  44. ?>
  45.  
  46. <form name="contactform" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  47. <table width="750px" cellspacing="10">
  48. <tr>
  49. <td valign="top">
  50. <label for="nick">Imię i nazwisko *</label>
  51. </td>
  52. <td valign="top">
  53. <input type="text" name="nick" maxlength="50" value="<?php echo $name; ?>" size="30">
  54. </td>
  55. </tr>
  56. <tr>
  57. <td valign="top">
  58. <label for="email">Adres e-mail *</label>
  59. </td>
  60. <td valign="top">
  61. <input type="text" name="email" maxlength="80" value="<?php echo $email; ?>" size="30">
  62. </td>
  63. </tr>
  64. <tr>
  65. <td valign="top">
  66. <label for="telephone">Numer telefonu</label>
  67. </td>
  68. <td valign="top">
  69. <input type="text" name="telephone" maxlength="30" value="<?php echo $telephone; ?>" size="30">
  70. </td>
  71. </tr>
  72. <tr>
  73. <td valign="top">
  74. <label for="other">Pytania, uwagi *</label>
  75. </td>
  76. <td valign="top">
  77. <textarea name="other" maxlength="1000" cols="25" rows="6"><?php echo $other; ?></textarea>
  78. </td>
  79. </tr>
  80. <tr>
  81. <td colspan="2" style="text-align:center">
  82. <input type="submit" value="Submit">
  83. </td>
  84. </tr>
  85. </table>
  86. </form>
  87.  
  88. <?php
  89. }
  90.  
  91. ?>



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: 14.10.2025 - 07:52