Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z formularzem kontaktowym
Forum PHP.pl > Forum > Przedszkole
senior.pol
Witam,

Formularz nie zwraca mi wszystkich danych wpisanych do niego. Kombinuję i kombinuję, ale efektów to nie przynosi.

  1. <?php
  2. }
  3.  
  4. if (isset ( $_POST ['contact-form-value'] )) {
  5. function ts_process_contact_form() {
  6. $data = array ();
  7. $err = array ();
  8. $headers = null;
  9. if (! wp_verify_nonce ( $_POST ['contact_nonce'], 'contact_form_submission' )) {
  10. $data ['status'] = 0;
  11. $err = array ();
  12. $err [] = "Invalid Form Submission";
  13. $data ['message'] = implode ( '<br>', $err );
  14. exit ( 0 );
  15. }
  16.  
  17. if ($_POST ['contact-form-value'] == 1) {
  18. $name = $field['Imię i nazwisko'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
  19. $phone = $field['Telefon'] = filter_var($_POST['phone'], FILTER_SANITIZE_STRING);
  20. $email = $field['Email'] = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
  21. $field['Message'] = filter_var($_POST['msg'], FILTER_SANITIZE_STRING);
  22.  
  23. foreach ( $field as $k => $v ) {
  24. if (trim ( $v ) == '') {
  25. $err [] = $k . ' ' . __ ( 'is required', 'marine' );
  26. }
  27. }
  28.  
  29. if (! $field ['Email'] ) {
  30. $err [] = __ ( 'Email is invalid', 'marine' );
  31. }
  32.  
  33. if (empty ( $err )) {
  34. // send the mail
  35.  
  36. $to = ot_get_option ( 'contact_form_email' );
  37. $headers = "From: $name <$email>" . "\r\n";
  38.  
  39. add_filter ( 'wp_mail_content_type', 'set_html_content_type' );
  40. function set_html_content_type() {
  41. return 'text/html';
  42. }
  43.  
  44. $subject = ot_get_option ( 'contact_form_subject' );
  45. if (empty($subject)) {
  46. $subject = __('Query', 'marine');
  47. }
  48.  
  49. $message_content = __('From:', 'marine').' '.$name."<br>";
  50. $message_content = __('Telefon:', 'marine').' '.$phone."<br>";
  51. $message_content .= __('Email:', 'marine').' <a href="mailto'.esc_attr($email).'">'.$email.'</a>'."<br>";
  52. $message_content .= __('Message:', 'marine').' '.$field['Message']."\n";
  53.  
  54. if (wp_mail ( $to, $subject, $message_content, $headers )) {
  55. $data ['status'] = 1;
  56. $data ['message'] = __( 'Message Sent', 'marine' );
  57. } else {
  58. $data ['status'] = 0;
  59. $data ['message'] = __( 'An Error occured.', 'marine' );
  60. }
  61.  
  62. remove_filter ( 'wp_mail_content_type', 'set_html_content_type' );
  63. } else {
  64. $data ['status'] = 0;
  65. $data ['message'] = implode ( '<br>', $err );
  66. }
  67. echo json_encode ( $data );
  68. exit ( 0 );
  69. }
  70. }
  71. add_action ( 'init', 'ts_process_contact_form' );
  72. }


  1. <form '.$style.' class="get-in-touch contact-form '. ts_get_animation_class($animation) . ' '.$skin_class.'" method="post">
  2. '.wp_nonce_field( 'contact_form_submission', 'contact_nonce', true,false).'
  3. <input type="hidden" name="contact-form-value" value="1" id=""/>
  4. <div class="iconic-input">
  5. <input type="text" name="name" placeholder="' . $name_label . '*">
  6. <i class="icons ' . $name_icon . '"></i>
  7. </div>
  8. <div class="iconic-input">
  9. <input type="text" phone="phone" placeholder="' . $phone_label . '">
  10. <i class="icons ' . $phone_icon . '"></i>
  11. </div>
  12. <div class="iconic-input">
  13. <input type="text" name="email" placeholder="' . $email_label . '*">
  14. <i class="icons ' . $email_icon . '"></i>
  15. </div>
  16. <textarea name="msg" placeholder="' . $message_label . '*"></textarea>
  17. <input type="submit" value="' . $send_label . '">
  18. <div class="iconic-button">
  19. <input type="reset" value="' . $clear_label . '">
  20. <i class="icons icon-cancel-circle-1"></i>
  21. </div>
  22. </form>


Dane, które nie docierają to: telefon i treść wiadomości. Co tu poprawić, aby wszystko było OK?
nospor
Podstawy HTML.... Przenosze

Zeby pole sie wyslalo to musi miec NAME
senior.pol
Cytat(nospor @ 21.02.2016, 23:51:39 ) *
Zeby pole sie wyslalo to musi miec NAME


facepalmxd.gif

Dzięki specool.gif
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.