Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z wysyłką
Forum PHP.pl > Forum > PHP
senior.pol
Witam,
Stworzyłem sobie mały formularz w html-u, ale mam problem z php, gdyż nie wiem co dalej zrobić, by on wysyłał dane do mnie.

Na razie mam coś takiego:
  1. <form id="formElem" name="formElem" action="" method="post">
  2. <fieldset class="step">
  3. <legend>Dane personalne</legend>
  4. <p>
  5. <label for="name">Imię i nazwisko</label>
  6. <input id="name" name="name" type="text" AUTOCOMPLETE=OFF />
  7. </p>
  8. <p>
  9. <label for="adres">Adres zamieszkania</label>
  10. <input id="adres" name="adres" type="text" AUTOCOMPLETE=OFF />
  11. </p>
  12. <p>
  13. <label for="telefon">Telefon</label>
  14. <input id="telefon" name="telefon" type="text" AUTOCOMPLETE=OFF />
  15. </p>
  16. <p>
  17. <label for="email">Email</label>
  18. <input id="email" name="email" type="email" AUTOCOMPLETE=OFF />
  19. </p>


itd. aż do
  1. <p class="submit">
  2. <input type="hidden" value="biuro@sternicy.com.pl" name="to" id="to" />
  3. <input type="hidden" value="rezerwacja.php" name="sendMailUrl" id="sendMailUrl" />
  4. <button id="registerButton" type="submit">Rezerwuj</button>
  5. </p>


W pliku .php natomiast:
  1. <?php
  2.  
  3. $name = $_POST['name'];
  4. $adres = explode(',', $_POST['adres'] );
  5. $telefon = explode(',', $_POST['telefon'] );
  6. $typrejsu = explode(',', $_POST['typrejsu'] );
  7. $liczbamiejsc = explode(',', $_POST['liczbamiejsc'] );
  8. $ubezpieczenie = explode(',', $_POST['ubezpieczenie'] );
  9. $platnosc = explode(',', $_POST['platnosc'] );
  10. $waluta = explode(',', $_POST['waluta'] );
  11. $platnik = explode(',', $_POST['platnik'] );
  12. $pesel = explode(',', $_POST['pesel'] );
  13. $zaliczka = explode(',', $_POST['zaliczka'] );
  14. $from = $_POST['email'];
  15.  
  16. $msg = "<b>Imię i nazwisko:</b> " .$_POST['imie'] ."<br>\n";
  17. $msg .= "<br>\n";
  18. $msg .= "<b>Adres zamieszkania:</b> " .$_POST['adres'] ."<br>\n";
  19. $msg .= "<b>Telefon:</b> " .$_POST['telefon'] ."<br>\n";
  20. $msg .= "<b>Adres email:</b> " .$_POST['email'] ."<br>\n";
  21. $msg .= "<b>Typ rejsu:</b> " .$_POST['typrejsu'] ."<br>\n";
  22. $msg .= "<b>Liczba rezerwowanych miejsc:</b> " .$_POST['liczbamiejsc'] ."<br>\n";
  23. $msg .= "<b>Dodatkowe ubezpieczenie:</b> " .$_POST['ubezpieczenie'] ."<br>\n";
  24. $msg .= "<b>Sposób płatności:</b> " .$_POST['platnosc'] ."<br>\n";
  25. $msg .= "<b>Imię i nazwisko Płatnika:</b> " .$_POST['platnik'] ."<br>\n";
  26. $msg .= "<b>PESEL Płatnika:</b> " .$_POST['pesel'] ."<br>\n";
  27. $msg .= "<b>Potwierdzenie wpłaty zaliczki:</b> " .$_POST['zaliczka'] ."<br>\n";
  28.  
  29. ?>


Ktoś ma pomysł co tu zrobić lub poprawić, aby zadziałał? Będę bardzo wdzięczny za każdą pomoc.
Pozdrawiam
lukaskolista
  1. <form id="formElem" name="formElem" action="" method="post">
action="skrypt.php"
senior.pol
Po kliknięciu buttona wysyłki, nadal nic się nie dzieje sad.gif

Jakiś pomysł?
Dominator
Jak sądzisz, co ma się dziać, jak nawet echa nie wstawiłeś ?
senior.pol
Teraz wygląda to tak:
  1. <form id="formElem" name="formElem" action="rezerwacja.php" method="post">
  2. <fieldset class="step">
  3. <legend>Dane personalne</legend>
  4. <p>
  5. <label for="name">Imię i nazwisko</label>
  6. <input id="name" name="name" type="text" AUTOCOMPLETE=OFF />
  7. </p>
  8. <p>
  9. <label for="adres">Adres zamieszkania</label>
  10. <input id="adres" name="adres" type="text" AUTOCOMPLETE=OFF />
  11. </p>
  12. <p>
  13. <label for="telefon">Telefon</label>
  14. <input id="telefon" name="telefon" type="text" AUTOCOMPLETE=OFF />
  15. </p>
  16. <p>
  17. <label for="email">Email</label>
  18. <input id="email" name="email" type="text" AUTOCOMPLETE=OFF />
  19. </p>
  20. <fieldset class="step">
  21. <legend>Szczegóły dotyczące rezerwacji</legend>
  22. <p>
  23. <label for="typrejsu">Typ rejsu</label>
  24. <select id="typrejsu" name="typrejsu">
  25. <option>xxxx</option>
  26. <option>xxxxx</option>
  27. </select>
  28. </p>
  29. <p>
  30. <label for="liczbamiejsc">Liczba rezerwowanych miejsc</label>
  31. <select id="liczbamiejsc" name="liczbamiejsc">
  32. </select>
  33. </p>
  34. <p>
  35. <label for="ubezpieczenie">Dodatkowe ubezpieczenie</label>
  36. <select id="ubezpieczenie" name="ubezpieczenie">
  37. <option>Tak</option>
  38. <option>Nie</option>
  39. </select>
  40. </p>
  41.  
  42. <fieldset class="step">
  43. <legend>Szczegóły płatności</legend>
  44. <p>
  45. <label for="platnosc">Sposób płatności</label>
  46. <select id="platnosc" name="platnosc">
  47. <option>Gotówka</option>
  48. <option>Przelew</option>
  49. </select>
  50. </p>
  51. <p>
  52. <label for="waluta">Waluta</label>
  53. <select id="waluta" name="waluta" AUTOCOMPLETE=OFF>
  54. <option>PLN</option>
  55. <option>EU</option>
  56. </select>
  57. </p>
  58. <p>
  59. <label for="platnik">Imię i nazwisko Płatnika</label>
  60. <input id="platnik" name="platnik" AUTOCOMPLETE=OFF />
  61. </p>
  62. <p>
  63. <label for="pesel">PESEL Płatnika</label>
  64. <input id="pesel" name="pesel" AUTOCOMPLETE=OFF />
  65. </p>
  66. <fieldset class="step">
  67. <legend>Szczegóły wpłaty zaliczki</legend>
  68. <p>
  69. xxxxxxxxxx
  70. </p>
  71. <p>
  72. <label for="zaliczka">Potwierdzam wpłatę zaliczki</label>
  73. <select id="zaliczka" name="zaliczka">
  74. <option>Tak</option>
  75. <option>Nie</option>
  76. </select>
  77. </p>
  78. <fieldset class="step">
  79. <legend>Potwierdzenie uczestnictwa w rejsie</legend>
  80. <p>
  81. Oświadczam, że zapoznałem(am) się z regulaminem rejsu i zezwalam na przetwarzanie moich danych osobowych na potrzeby rezerwacji
  82. miejsca w czasie rejsu w serwisie xxxxxx
  83. </p>
  84. <p class="submit">
  85. <button id="registerButton" type="submit" name="submit">Rezerwuj</button>
  86. </p>
  87. <?php echo $error; ?>
  88. </form>


  1. <?php
  2.  
  3. $email = 'xxx';
  4.  
  5. $name = explode(',', $_POST['name'];
  6. $adres = explode(',', $_POST['adres'] );
  7. $telefon = explode(',', $_POST['telefon'] );
  8. $email = explode(',', $_POST['email'];
  9. $typrejsu = explode(',', $_POST['typrejsu'] );
  10. $liczbamiejsc = explode(',', $_POST['liczbamiejsc'] );
  11. $ubezpieczenie = explode(',', $_POST['ubezpieczenie'] );
  12. $platnosc = explode(',', $_POST['platnosc'] );
  13. $waluta = explode(',', $_POST['waluta'] );
  14. $platnik = explode(',', $_POST['platnik'] );
  15. $pesel = explode(',', $_POST['pesel'] );
  16. $zaliczka = explode(',', $_POST['zaliczka'] );
  17.  
  18. if(!empty($name) && !empty($adres) && !empty($telefon) && !empty($email) && !empty($typrejsu) && !empty($liczbamiejsc) && !empty($ubezpieczenie) && !empty($platnosc) && !empty($waluta) && !empty($platnik) && !empty($pesel) && !empty($zaliczka)) {
  19.  
  20. function checkMail($checkmail) {
  21. if(filter_var($checkmail, FILTER_VALIDATE_EMAIL))
  22. return checkdnsrr(array_pop(explode("@",$checkmail)),"MX");
  23. return false;
  24. }
  25. }
  26.  
  27.  
  28. if(checkMail($email)) {
  29.  
  30. $ip = $_SERVER['REMOTE_ADDR'];
  31. $host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
  32.  
  33. $mailzaliczka = "Treść wiadomości:n$zaliczkanOd: $name, $email ($ip, $host)";
  34.  
  35. $mailHeader = "From: $name <$email>";
  36.  
  37. @mail($email, 'Formularz kontaktowy', $mailzaliczka, $mailHeader) or die('Błąd: wiadomość nie została wysłana');
  38.  
  39. echo 'Wiadomość została wysłana';
  40. } else {
  41. echo 'Adres e-mail jest niepoprawny';
  42. }
  43. } else {
  44.  
  45. echo 'Wypełnij wszystkie pola formularza';
  46. }
  47.  
  48. }
  49. ?>


Coś tu dalej jest nie tak sad.gif
L00zak
czy mnie coś ominęło czy teraz input submit to button submit? bo js to tu nie widzę :|

<button id="registerButton" type="submit" name="submit">Rezerwuj</button>
senior.pol
Jest js

Oto kod:

  1. $(function() {
  2. var fieldsetCount = $('#formElem').children().length;
  3. var current = 1;
  4. var stepsWidth = 0;
  5. var widths = new Array();
  6. $('#steps .step').each(function(i){
  7. var $step = $(this);
  8. widths[i] = stepsWidth;
  9. stepsWidth += $step.width();
  10. });
  11. $('#steps').width(stepsWidth);
  12. $('#formElem').children(':first').find(':input:first').focus();
  13. $('#navigation').show();
  14.  
  15. $('#navigation a').bind('click',function(e){
  16. var $this = $(this);
  17. var prev = current;
  18. $this.closest('ul').find('li').removeClass('selected');
  19. $this.parent().addClass('selected');
  20.  
  21. current = $this.parent().index() + 1;
  22.  
  23. $('#steps').stop().animate({
  24. marginLeft: '-' + widths[current-1] + 'px'
  25. },500,function(){
  26. if(current == fieldsetCount)
  27. validateSteps();
  28. else
  29. validateStep(prev);
  30. $('#formElem').children(':nth-child('+ parseInt(current) +')').find(':input:first').focus();
  31. });
  32. e.preventDefault();
  33. });
  34.  
  35. $('#formElem > fieldset').each(function(){
  36. var $fieldset = $(this);
  37. $fieldset.children(':last').find(':input').keydown(function(e){
  38. if (e.which == 9){
  39. $('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
  40. $(this).blur();
  41. e.preventDefault();
  42. }
  43. });
  44. });
  45.  
  46. function validateSteps(){
  47. var FormErrors = false;
  48. for(var i = 1; i < fieldsetCount; ++i){
  49. var error = validateStep(i);
  50. if(error == -1)
  51. FormErrors = true;
  52. }
  53. $('#formElem').data('errors',FormErrors);
  54. }
  55.  
  56. function validateStep(step){
  57. if(step == fieldsetCount) return;
  58.  
  59. var error = 1;
  60. var hasError = false;
  61. $('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input:not(button)').each(function(){
  62. var $this = $(this);
  63. var valueLength = jQuery.trim($this.val()).length;
  64.  
  65. if(valueLength == ''){
  66. hasError = true;
  67. $this.css('background-color','#FFEDEF');
  68. }
  69. else
  70. $this.css('background-color','#FFFFFF');
  71. });
  72. var $link = $('#navigation li:nth-child(' + parseInt(step) + ') a');
  73. $link.parent().find('.error,.checked').remove();
  74.  
  75. var valclass = 'checked';
  76. if(hasError){
  77. error = -1;
  78. valclass = 'error';
  79. }
  80. $('<span class="'+valclass+'"></span>').insertAfter($link);
  81.  
  82. return error;
  83. }
  84. $('#registerButton').bind('click',function(){
  85. if($('#formElem').data('errors')){
  86. alert('Prosimy poprawić dane w formularzu !');
  87. return false;
  88. }
  89. });
  90. });
  91.  
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.