Ocena wątku:
  • 1 głosów - średnia: 5
  • 1
  • 2
  • 3
  • 4
  • 5
Problem z AjaxContact- nie działa po modyfikacji...
#1
Witam.
Mam mały problem z AjaxContact, dodałem kilka pól do niego i tam wprowadziłem modyfikacje w plikach .php lecz teraz nie działa...
Nie wiem gdzie zrobiłem błąd bo wydaje mi się że jest wszystko dobrze...
Zamieszczam kody d 4 plików od niego.
Proszę o pilną pomoc.
Pozdrawiam Smile

formularz.html
Kod PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<
head>
  <
title>bContact &mdashAJAX Contact FORM</title>
    <
meta name="robots" content="index, follow" />
    <
meta name="description" content="" />
    <
meta name="keywords" content="" />
    <
link type="text/css" href="media/images/css/layout.css" rel="stylesheet" />
    <
meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
    <
script type="text/javascript" src="media/js/jquery.js"></script>
    <
script type="text/javascript" src="media/js/bcontact.js"></script>
</
head>
<
body>
      <!-- 
Start bContact Wrapper -->
      <
div id="bcontact">
            
            <!-- 
Start bContact form -->
            <
div id="bcontact_form">
                  
                  <
form method="post" action="">
                  <
fieldset>
                            <
legend>Proszę wypełnić wszystkie pola formularza!</legend>
                            
                            <
p>
                              <
label for="name">Imię i nazwisko zamawiającego:</label>
                              <
input type="text" name="name" id="name" />
                              <
span id="name_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="namez">Imię i nazwisko zmarłego:</label>
                              <
input type="text" name="namez" id="namez" />
                              <
span id="namez_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="email">Email:</label>
                              <
input type="text" name="email" id="email" />
                              <
span id="email_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="phone">Nrtel. (z kierunkowym):</label>
                              <
input type="text" name="phone" id="phone" />
                              <
span id="phone_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="zgon">Data zgonu zmarłego (dd-mm-RRRR):</label>
                              <
input type="text" name="zgon" id="zgon" />
                              <
span id="zgon_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="spoczynek">Miejsce spoczynku zmarłego:</label>
                              <
input type="text" name="spoczynek" id="spoczynek" />
                              <
span id="spoczynek_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="pakiet">Pakiet</label>
                              <
select name="pakiet" id="pakiet">
                              <
option selected="selected" id="pakiet">mały</option>
                              <
option id="pakiet">średni</option>
                              <
option id="pakiet">duży</option>
                              </
select>
                              <
span id="pakiet_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="grob">Grób</label>
                              <
select name="grob" id="grob">
                              <
option selected="selected" id="grob">pojedynczy</option>
                              <
option id="grob">podwójny</option>
                              <
option id="grob">rodzinny</option>
                              </
select>
                              <
span id="grob_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="znicz">Dodatkowy znicz</label>
                              <
select name="znicz" id="znicz">
                              <
option selected="selected" id="znicz">-</option>
                              <
option id="znicz">mały</option>
                              <
option id="znicz">średni</option>
                              <
option id="znicz">duży</option>
                              </
select>
                              <
span id="znicz_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="uslugi">Inne usługi</label>
                              <
select name="uslugi" id="uslugi">
                              <
option selected="selected" id="uslugi">-</option>
                              <
option id="uslugi">odśnieżanie pomnika</option>
                              <
option id="uslugi">odśnieżanie pomnika terenu wokół</option>
                              <
option id="uslugi">zagospodarowanie bezpośrednie okolicy grobu</option>
                              </
select>
                              <
span id="uslugi_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="message">Dodatkowa wiadomość*:</label>
                            </
p>
                            
                            <
p>
                              <
textarea name="message" id="message" rows="" cols=""></textarea>
                              <
span id="message_error" class="error_message"></span>
                            </
p>
                            
                            <
p>
                              <
label for="anti_bot">= ?</label>
                              <
input type="text" name="anti_bot" id="anti_bot" maxlength="1" />
                              <
span id="anti_bot_error" class="error_message anti_bot"></span>
                            </
p>
                            
                            <
class="bcontact_submit">
                              <
input type="submit" value="Send message" />
                            </
p>
                  </
fieldset>
                  </
form>
                  
            </
div>
            <!-- 
end of bContact form -->
            
            <!-- 
Start bContact sending -->
            <
div id="bContact_send_email">
                  <
h2>Wysyłanie zamówienia...</h2>
                  <
p><img src="media/images/loader.gif" alt="" /></p>
            </
div>
            <!-- 
end of bContact sending -->
            <
div id="bContact_email_sent">
                <
h2>Wysłano zamówienie!</h2>
                <
p>Dziękuję <strong id="sender_name"></strong>, Twoje zamówienie zostało przyjęte.</p>
            </
div>
      
      </
div>
      <!-- 
end of bContact Wrapper -->
</
body>
</
html

bContact.php
Kod PHP:
<?php
/**
 * @package     bContact
 * @version     1.0 (2009)
 * @author      Michell Hoduń <[email protected]>
 * @copyright        Copyright (c) 2009, Michell Hoduń
 */
 
  // For security reason
  
define ('bContact_PATH'dirname(__FILE__).'/');

  
// Load bContact Core & Config
  
require bContact_PATH.'bContact_Config.php';
  
  if (
$_POST)
  {
    
$validation bContact::instance()->valid_form ($_POST);
    
    if(
$validation['errors_count'] === 0)
    {
        
// Send message
        
bContact::instance()->send_email ($_POST['name'], $_POST['namez'], $_POST['email'], $_POST['phone'], $_POST['zgon'], $_POST['spoczynek'], $_POST['pakiet'], $_POST['grob'], $_POST['znicz'], $_POST['uslugi'], $_POST['message']);
    }
    
    
// Print validation status and if is errors print it
    
echo json_encode($validation);
  } 

bContact.class
Kod PHP:
<?php if(!defined('bContact_PATH')) die ('bContact does not allow direct access to script.');
/**
 * @package     bContact
 * @version     1.0 (2009)
 * @author      Michell Hoduń <[email protected]>
 * @copyright        Copyright (c) 2009, Michell Hoduń
 */
 
  
class bContact {
      
      protected static 
$_instance;
      
      
// Default bContact settings
      
protected static $_config = array
      (
        
'message_subject' => 'Zamówienie:'// Message subject, can u use {user_subject} to append user subject.
        
'message_recipient' => '[email protected]'// E-mail address where to message will come.
        
'email_template' => 'Wiadomość od: {name} <br />
        Imię zmarłego i nazwisko: {namez} <br />
    IP i email: <small>({ip_address})</small> &mdash; {sender_email} <br />
    nr. telefonu: {phone_number} <br />
    Data zgonu zmarłego: {zgon} <br /> 
    Miejsce spoczynku zmarłego: {spoczynek} <br /> 
    Pakiet: {pakiet} <br />
    Grób: {grob} <br />
    Dodatkowy znicz: {znicz} <br /> 
    Inne usługi: {uslugi} <br /> 
    Data wysłania zamówienia {sent_date}.<br />
    Dodatkowa wiadomość: <p>{message}</p><br />'
// Default email template
        
        // Required form inputs, comment (before input name add: //) if u want do it unrequired or uncomment if u want do it required.
        
'required_inputs' => array
        (
          
'name',
          
'namez',
          
'email',
          
'phone',
          
'zgon',
            
'spoczynek',
          
'pakiet',
          
'grob',
          
'znicz',
          
'uslugi',
          
'message',
          
'anti_bot'
        
)
      );
      
      
// Get or create script instance
      
public static function instance($config = array())
      {
          if(
self::$_instance === NULL)
          {
              
self::$_instance = new bContact ($config);
          }
          
          return 
self::$_instance;
      }
      
      public function 
__construct ($config)
      {
        foreach (
$config as $key => $val)
        {
          
self::$_config[$key] = $val;
        }
      }
      
     
/**
      * Email `helper`
      *
      * @param string $name - sender name
      * @param string $sender_email - sender e-mail address
      * @param string $phone_number - sender phone number
      * @param string $subject - message subject
      * @param string $message - message
      *
      * @return void
      */
      
public static function send_email ($name$namez$sender_email$phone_number$zgon$spoczynek$pakiet$grob$znicz$uslugi$message)
      {
          
$subject str_replace(, $subjectself::$_config['message_subject']);
          
$template strtr(self::$_config['email_template'], array
                                                                   (
                                                                    
'{name}' => $name,
                                                                    
'{namez}' => $namez,
                                                                    
'{sender_email}' => $sender_email,
                                                                    
'{ip_address}' => $_SERVER['REMOTE_ADDR'],
                                                                    
'{phone_number}' => $phone_number,
                                                                    
'{zgon}' => $zgon,
                                                                    
'{spoczynek}' => $spoczynek,
                                                                    
'{pakiet}' => $pakiet,
                                                                    
'{grob}' => $grob,
                                                                    
'{znicz}' => $znicz,
                                                                    
'{uslugi}' => $uslugi,
                                                                    
'{sent_date}' => date('Y-m-d H:i:s'),
                                                                    
'{message}' => $message
                                                                   
));
          
          
// Email headers
          
$headers  "From: $name <$sender_email>\r\n";
          
$headers .= "Reply-To: $sender_email\r\n";
          
$headers .= "Return-Path: '.$sender_email.'\r\n";
          
$headers .= "X-Mailer: bContact\n";
          
$headers .= 'MIME-Version: 1.0' "\n";
          
$headers .= 'Content-type: text/html; charset=utf-8' "\r\n";
          
          return 
mail(self::$_config['message_recipient'], $subject$template$headers);
      }
      
      
     
/**
      * Validation `helper` returning errors if found.
      *
      * @param array $data
      *
      * @return array
      */
      
public static function valid_form ($data = array())
      {
          
$errors_count 0;
          
          foreach (
$data as $key => $value)
          {
              
$errors[$key] = 'false';
              
              if(
in_array($keyself::$_config['required_inputs']) AND $value === '')
              {
                  
$errors[$key] = 'This field is required.';
                  
$errors_count++;
                  continue;
              }

              if(
$key === 'email' AND !preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', (string) $value))
              {
                  
$errors[$key] = 'Please enter valid email.';
                  
$errors_count++;
                  continue;
              }
              
              if (
$key === 'anti_bot' AND $value != 8)
              {
                  
$errors[$key] = 'Please enter valid integer.';
                  
$errors_count++;
                  continue;
              }
          }
          
          return array(
'errors' => $errors'errors_count' => $errors_count);
      }
  } 

bContact_Config
Kod PHP:
<?php if(!defined('bContact_PATH')) die ('bContact does not allow direct access to script.');
/**
 * @package     bContact
 * @version     1.0 (2009)
 * @author      Michell Hoduń <[email protected]>
 * @copyright        Copyright (c) 2009, Michell Hoduń
 */
  
  // Load bContact class
  
require bContact_PATH.'bContact.class.php';
  
  
$bContact_config = array
  (
    
'message_subject' => 'Zamówienie:'// Message subject, can u use {user_subject} to append user subject.
    
'message_recipient' => '[email protected]'// E-mail address where to message will come.
    
'email_template' => 'Wiadomość od: {name} <br />
    Imię i nazwisko zmarłego: {namez} <br />
    IP i email: <small>({ip_address})</small> &mdash; {sender_email} <br />
    nr. telefonu: {phone_number} <br />
    Data zgonu zmarłego: {zgon} <br />
    Miejsce spoczynku zmarłego: {spoczynek} <br />
    Pakiet: {pakiet} <br />
    Grób: {grob} <br />
    Dodatkowy znicz: {znicz} <br />
    Inne usługi: {uslugi} <br />
    Data wysłania zamówienia {sent_date}. <br />
    <br />Dodatkowa wiadomość: <p>{message}</p><br />'
,
    
    
// Required form inputs, comment (before input name add: //) if u want do it unrequired or uncomment if u want do it required.
    
'required_inputs' => array
    (
      
'name',
      
'namez',
      
'email',
      
'phone',
      
'zgon',
      
'spoczynek',
      
'pakiet',
      
'grob',
      
'znicz',
      
'uslugi',
      
'message',
      
'anti_bot'
    
)
  );
  
  
// Create instance
  
bContact::instance($bContact_config); 
Odpowiedz
#2
Kiedy nauczą się w końcu pisać w ojczystym języku? A może powiesz co to znaczy "nie działa" wg Ciebie i czym się objawia?
Odpowiedz


Podobne wątki…
Wątek: Autor Odpowiedzi: Wyświetleń: Ostatni post
  galeria nie działa w IE Nicorrtiss 2 3,379 02-08-2013, 22:42
Ostatni post: Nicorrtiss
  Css działa tylko na... IE catalunya 5 4,618 21-12-2012, 15:04
Ostatni post: atp
  Strona na DIV-ach nie działa w IE i Operze kazelot2000 7 5,642 03-08-2012, 16:12
Ostatni post: kazelot2000
  pokazuje mi się błąd strona nie działa jabol73 1 2,292 28-07-2012, 18:17
Ostatni post: Pedro84
  Formularz nie działa raxiq 9 5,283 26-06-2012, 12:32
Ostatni post: raxiq

Skocz do:


Użytkownicy przeglądający ten wątek:
Sponsorzy i przyjaciele
SeoHost.pl