Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wysłanie formularza
gilbertos
post
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 22.05.2012

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


Przy użyciu <input type= "button" value type="submit" formularz normalnie wysyła wiadomość ze strony. Problem z wysyłaniem występuje w chwili kiedy chcę wysłać za pomocą <a href="#" class="alt" onClick="document.contacts-form.submit(); ">Wyślij</a>. Proszę o pomoc.
  1. <?php
  2.  
  3.  
  4. if($_POST['submit'])
  5. {
  6. if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['subject']))
  7. {
  8. $error = true;
  9. }
  10. else
  11. {
  12. $to = "lukaszkoteluk@gmail.com";
  13.  
  14. $name = ($_POST['name']);
  15. $email = ($_POST['email']);
  16. $subject = ($_POST['subject']);
  17. $information = ($_POST['information']);
  18. $message = ($_POST['message']);
  19. $date = ($_POST['data']);
  20.  
  21. $temat = "Formularz kontaktowy";
  22.  
  23. $messages = "Imię i nazwisko: $name \r\n E-mail: $email \r\n Temat: $subject \r\n Skąd o nas wiesz: $information \r\n Wiadomość: $message";
  24. $headers = "From: . $name";
  25. $mailsent = mail($to, $temat, $messages, $headers);
  26.  
  27. if($mailsent)
  28. {
  29. $sent = true;
  30. }
  31. }
  32. }
  33.  
  34. ?>
  35. <!DOCTYPE html>
  36. <html lang="pl">
  37. <head>
  38. <meta charset="utf-8" />
  39. <title>CompandCare</title>
  40. <link rel="stylesheet" href="main.css" type="text/css">
  41. <link rel="stylesheet" href="grid.css" type="text/css" media="all">
  42. </head>
  43.  
  44. <body id="index" class="home">
  45.  
  46. <header id="banner" class="body">
  47. <img src="images/logo.png" alt="CompandCare"/>
  48.  
  49. <nav>
  50. <ul>
  51. <li><a href="home.html">home</a></li>
  52. <li><a href="uslugi.html">usługi</a></li>
  53. <li class="active"><a href="kontakt.php">kontakt</a></li>
  54. </ul>
  55. </nav>
  56.  
  57. </header><!-- banner -->
  58.  
  59. <footer id="contentinfo" class="body">
  60. <address id="about" class="vcard author">
  61. <div class="bottom">
  62. <div class="container">
  63. <div class="clearfix">
  64. <div class="grid3 first">
  65. <h3>Kontakt</h3>
  66. <div class="wrapper">
  67. <dl class="address">
  68. <dd><span>Telefon kom:</span>600090437</dd>
  69. <dd><span>E-mail:</span><a href="mailto:lukaszkoteluk@gmail.com">lukaszkoteluk@gmail.com</a></dd>
  70. </dl>
  71. </div>
  72. </div>
  73. <div class="grid6">
  74. <h3>Formularz kontaktowy</h3>
  75. <?php if($error == TRUE) { ?>
  76. <p class="error">Nie wypełniłeś wszystkich pól w formularzu. Wypełnij pozostałe pola.</p>
  77. <?php } if ($sent == TRUE) { ?>
  78. <p class="sent">Dziękujemy. Twój e-mail został wysłany prawidłowo. Odpowiemy na niego w przeciągu 24 godzin.</p>
  79. <?php } ?>
  80. <form name="contacts-form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="contacts-form">
  81. <fieldset>
  82. <div class="grid3 first">
  83. <label for="name">Imię i nazwisko:<br />
  84. <input type="text" name="name" />
  85. </label>
  86. <label for="email">E-mail:<br />
  87. <input type="email" name="email" />
  88. </label>
  89. <label for="subject">Temat:<br />
  90. <input type="text" name="subject" />
  91. </label>
  92. <label for="information">Skąd o nas wiesz:<br />
  93. <select name="information">
  94. <option value="z sieci Web">Z sieci Web</option>
  95. <option value="ulotki/ogłoszenia">ulotki/ogłoszenia</option>
  96. <option value="od znajomego">od znajomego</option>
  97. </select>
  98. </label>
  99. </div>
  100. <div class="grid3">Wiadomość:<br />
  101. <textarea name="message"></textarea>
  102. <!-- <input type="submit" name="submit" class="submit" value="Wyślij"> -->
  103. <div class="alignright">
  104.  
  105. <a href="#" class="alt" onClick="document.getElementById('contacts-form').reset(); ">Wyczyść</a> &nbsp; &nbsp;
  106. <a href="#" class="alt" onClick="document.contacts-form.submit(); ">Wyślij</a>
  107. <!-- <noscript>
  108. <input type="submit" value="Wyślij" style="border: none; background-color: transparent; text-decoration: underline; />
  109. </noscript> -->
  110. </div>
  111. </div>
  112. </fieldset>
  113. </form>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <!--<span class="bio"></span>-->
  119. </address>
  120. <p>Copyright ˆ 2012 Comp&Care<br>All Rights Reserverd.</p>
  121. </footer><!-- /#contentinfo -->
  122. </body>
  123. </html>
  124.  
Go to the top of the page
+Quote Post

Posty w temacie
- gilbertos   Wysłanie formularza   24.05.2012, 11:12:16
- - com   [PHP] pobierz, plaintext <?php if($_POST...   24.05.2012, 14:59:29
- - gilbertos   Dzięki już działa   24.05.2012, 20:19:17


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: 23.12.2025 - 19:36