Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
> [JavaScript][PHP]Formularz w PHP oraz jQuery, wiadomosci nie dochodza
#1
Witam,jestem w trakcie tworzenia własnej stronki i napotkałem problem którego nie mogę rozwiązać.Niestety nie znam za bardzo języka php a problem może być "banalny" do rozwiązania dla osób które pracują w tym języku na co dzień.Oto adres mojej strony i formularza kontaktowego http://pawelradzieta.xtreemhost.com/index1.php .Jak widać formularz prawidłowo zachowuje się gdy pola nie są wypełnione i próbujemy wysłać wiadomość oraz jest potwierdzenie kiedy wiadomość została wysłana lecz wiadomości niestety nie dochodą na moja skrzynkę w gmail.Formularz oczywiście nie jest mojego autorstwa został ściągnięty z http://madebyblaze.com/examples/awesomeform/. Paczka składa się z kilku plików index.php(zawarty jest w nim jquery) ,send_email.php trzech arkuszy styli oraz zdjęć.Zmian dokonałem tylko w index.php gdzie zmieniłem nazwy obok formularzy na polskie a także w send email_php gdzie ustawiłem swój email na gmailu.Moja stronka stoi na darmowym serwerze xtreemhost.com może tutaj jest problem ?Chciałbym także z Waszą pomocą ulepszyć ten formularz to znaczy chciałbym aby po wysłaniu wiadomości pola ulegały samoczynnemu oczyszczaniu,bo teraz jest tak iż pole czyści się ale dopiero po odświeżeniu strony,czy taki zabieg jest trudny do wykonania?, Będę bardzo wdzięczny za każdą pomoc..POZDRAWIAM

Tak wyglądają ustawienia w send_email

Kod PHP:
1.
      
<?php
   2.
      
// =====================================
   
3.
      
// name: Ajax'd Form with Fancy Email
   
4.
      
// version: 1.3
   
5.
      
// author: Blaze Pollard
   
6.
      
// date: 07.16.10
   
7.
      
// =====================================
   
8.
       
   9.
      $message 
'<html><body>';
  
10.
      
// You can change the header to be an image, just add the <img> tag.
  
11.
      $message 
.= '<h1>Hey, this is the header.</h1>';
  
12.
       
  13.
      
// Table Layout
  
14.
      $message 
.= '<table rules="all" style="border-color: #666;" cellpadding="10">';
  
15.
      $message 
.= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" strip_tags($_POST['name']) . "</td></tr>";
  
16.
      $message 
.= "<tr><td><strong>Email:</strong> </td><td>" strip_tags($_POST['email']) . "</td></tr>";
  
17.
      $message 
.= "<tr><td><strong>Subject:</strong> </td><td>" strip_tags($_POST['subject']) . "</td></tr>";
  
18.
      $message 
.= "<tr><td><strong>Message:</strong> </td><td>" strip_tags($_POST['message']) . "</td></tr>";
  
19.
      $message 
.= "</table>";
  
20.
      $message 
.= "</body></html>";
  
21.
       
  22.
      
// Email Config
  
23.
      $subject 
"Contact form submitted!";
  
24.
      $email_to 
'[email protected]'// Insert Email Address
  
25.
      $body 
= <<<HTML
  26.
      
$message
  27.
      HTML;
  
28.
       
  29.
      $headers 
.= "Reply-To: $email\r\n";
  
30.
      $headers 
"From: $email\r\n";
  
31.
      $headers 
.= "Content-type: text/html\r\n";
  
32.
       
  33.
       
  34.
      
if(mail($email_to$subject$message$headers)){
  
35.
      
echo 'sent'// we are sending this text to the ajax request telling it that the mail is sent..
  
36.
      
}else{
  
37.
      
echo 'failed';// ... or this one to tell it that it wasn't sent
  
38.
      
}
  
39.
      ?>
  40.
       
  41.
       
  42. 

a tak to wygląda w index.php
Kod:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Przykładowy opis"/>
<meta name="keywords" content="Słowa kluczowe"/>
<meta name='description' content='' />
                <meta name='keywords' content='' />
                <meta name='rating' content='general' />
                <meta name='author' content='' />
                <meta name='robots' content='index, follow' />
<title>Portfolio - Radzięta Paweł</title>
<link media='screen' href='css/style.css' type='text/css' rel='stylesheet' />
<link href="styl.css" rel="stylesheet" type="text/css" />

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script> <!-- jQuery -->
                <script type='text/javascript'>
                // Form
                $(document).ready(function(){
                $('#send_message').click(function(e){
                                // Stop the form from being submitted
                e.preventDefault();
                    var error = false;
                var name = $('#name').val();
                    var email = $('#email').val();
                var subject = $('#subject').val();
                var message = $('#message').val();
          
                if(name.length == 0){
                        var error = true;
                        $('#name_error').fadeIn(500);
                }else{
                        $('#name_error').fadeOut(500);
                }
                if(email.length == 0 || email.indexOf('@') == '-1'){
                        var error = true;
                        $('#email_error').fadeIn(500);
                }else{
                        $('#email_error').fadeOut(500);
                }
                if(subject.length == 0){
                        var error = true;
                        $('#subject_error').fadeIn(500);
                }else{
                        $('#subject_error').fadeOut(500);
                }
                if(message.length == 0){
                        var error = true;
                        $('#message_error').fadeIn(500);
                }else{
                        $('#message_error').fadeOut(500);
                }
          
                if(error == false){
                // Disable the submit button to avoid spamming
                // Change the button text to Sending...
                $('#send_message').attr({'disabled' : 'true', 'value' : 'Sending...' });
                $.post("send_email.php", $("#contact_form").serialize(),function(result){
                                if(result == 'sent'){
                         $('#cf_submit_p').remove();
                         $('#mail_success').fadeIn(500);
                    }else{
                         $('#mail_fail').fadeIn(500);
                         $('#send_message').removeAttr('disabled').attr('value', 'Send The Message');
                        }
                        });
                }
                });    
        });
              
                </script>
                <link rel='shortcut icon' href='favicon/.ico' /> <!-- favicon -->
                <link rel='apple-touch-icon' href='favicon/.png' /> <!-- Apple Touch Icon -->
      
                <!-- IE6, Sorry -->
                <!--[if lte IE 6]>
                        <link type="text/css" rel="stylesheet" href="css/obsolete.css">
                        </head>
                        <body>
                                <h6>It has been found that the browser in use is Internet Explorer 6.0 or a previous version. Please visit this website with a more recent browser. Thanks.</h6>
                <![endif]-->
              



</head>

<style type="text/css">

#centrum{
        position:absolute;
        left: 532px;
        top: 492px;
        width: 83px;
        height: 139px;
}

#centrum .foto1{
        position: absolute;
        background-repeat:no-repeat;
        left:-208px;
        bottom:49px;
        height:348px;
        width: 435px;
}

#centrum .foto2{
      
        position: absolute;
        background-repeat:no-repeat;
        height:222px;
        left: 22px;
        top: -40px;
        width: 344px;}


</style>


<body>


  <div id="wrapper">
  <div id="nic"></div>

  <div id ="shadow1"></div>
  <div id="tlo">
  <div id ="top">


      <h1><a href="index.html">Portfolio</a></h1></div>
      
      
      <div id="pasek"></div>
      <div id="szarypasek">
<ul id="menu">
              <li class="omnie"><a href="o mnie.html">Home</a></li>
              <li class="galeria"><a href="galeria.html">About</a></li>
              <li class="cv"><a href="cv.html">Contact</a></li>
              <li class="kontakt"><a href="index1.php">KONTAKT</a></li>
              <li class="inne"><a href="inne.html">INNE</a></li>
        </ul>
      
      </div>
      <div id="centrum">
        <div class="foto1">
    
       <h3>Kontakt</h3>
        <form action='index.php' method='post' id='contact_form'>
                <div>
                        <label>Nazwisko:</label><span id='name_error' class='error'> Prosze podac imię.</span><br/>
                        <input type='text' name='name' id='name' class='input-text'>
                </div>
                <div>
                        <label>Adres email:</label><span id='email_error' class='error'> Proszę podać adres email.</span><br/>
                        <input type='text' name='email' id='email' class='input-text'>
                </div>
                <div>                                                  
                        <label>Temat:</label><span id='subject_error' class='error'>Wypełnij pole temat</span><br/>
                        <input type='text' name='subject' id='subject' class='input-text'>
                </div>
                <div>
                        <label>Wiadomość:</label><span id='message_error' class='error'>Pole wiadomość nie moze być puste</span><br/>
                        <textarea name='message' id='message' class='input-text'></textarea>
                </div>
                <div>
                <p id='mail_success' class='success'><strong>Dziękuje!.</strong> The mailman is on his way.</p>
                <p id='mail_fail' class='error'>Przepraszamy spróbuj pozniej.</p>
                <p id='cf_submit_p'>
                        <input type='submit' id='send_message' value='send'>
                </p>
                </div>
        </form>
      

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12605747-12']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
      
      
      
        </div>
    
  
    
     <div class="foto2"></div>
      
    
      
</div>
    <div id="dolnypasek">
<div class="kontakt1"><a href="kontakt.html">
        <p>kontakt</p>
        </a></div>
        <div class="omnie1"><a href="o mnie.html">
        <p>omnie</p>
        </a></div>
        <div class="home1"><a href= "index.html">
        <p>home</p>
        </a></div>
        <div class="copyright"></div>
    </div>
</div>
      <div id ="shadow2"></div>
    
    
      </div>
  
  
  
  </body>
  </html>
Odpowiedz


Podobne wątki…
Wątek: Autor Odpowiedzi: Wyświetleń: Ostatni post
  Jak zrobic Formularz Kontaktowy na stronie ? Kodarth 191 255,843 06-04-2021, 16:25
Ostatni post: zerin
  Walidacja zdjęć + formularz harvester2001 6 5,988 24-03-2014, 19:01
Ostatni post: harvester2001
  Smarty, książki oraz Szablon HTML5 Morfeusz_2005 1 2,636 18-11-2013, 14:34
Ostatni post: prawdziwypiotrek
  php formularz - wszystkie pola muszą być wypełnione d3d3d3 2 3,636 01-10-2013, 14:16
Ostatni post: Kartofelek
  [PHP] Formularz mailowy - wysyłanie wiadomości spolprog 7 6,496 05-09-2013, 17:13
Ostatni post: Engine

Skocz do:


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