Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Formularz kontaktowy - problem
-bats_-
post
Post #1





Goście







Witam. Dostał mi się w ręce szablon, HTML+JS, w którym występuje formularz kontaktowy. Do formularza podpięty jest skrypt PHP (poniżej). W dokumentacji nie dostałem za wiele, proszę więc o pomoc tu - czy za pomocą takiego skryptu można cokolwiek wysłać? Wydaje mi się że sam e-mail do podmiany to za mało? Nie brakuje tu czegoś? Wyjaśni mi ktoś proszę, w kilku słowach co tu jest wykonywane?

  1. <?php
  2.  
  3. if(!$_POST) exit;
  4.  
  5. function tommus_email_validate($email) { return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email); }
  6.  
  7. $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $comments = $_POST['comments'];
  8.  
  9. if(trim($name) == '') {
  10.  
  11. exit('<div class="error_message">Attention! You must enter your name.</div>');
  12.  
  13. } else if(trim($name) == 'Name *') {
  14.  
  15. exit('<div class="error_message">Attention! You must enter your name.</div>');
  16.  
  17. } else if(trim($email) == '') {
  18.  
  19. exit('<div class="error_message">Attention! Please enter a valid email address.</div>');
  20.  
  21. } else if(!tommus_email_validate($email)) {
  22.  
  23. exit('<div class="error_message">Attention! You have entered an invalid e-mail address.</div>');
  24.  
  25. } else if(trim($phone) == '') {
  26.  
  27. exit('<div class="error_message">Attention! Please enter a valid phone number.</div>');
  28.  
  29. } else if(!is_numeric($phone)) {
  30.  
  31. exit('<div class="error_message">Attention! Phone number can only contain digits.</div>');
  32.  
  33. } else if(trim($comments) == 'Comment *') {
  34.  
  35. exit('<div class="error_message">Attention! Please enter your message.</div>');
  36.  
  37. } else if(trim($comments) == '') {
  38.  
  39. exit('<div class="error_message">Attention! Please enter your message.</div>');
  40.  
  41. } if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); }
  42.  
  43. $address = 'ADRES@EMAIL.XYZ';
  44.  
  45. $e_subject = 'You\'ve been contacted by ' . $name . '.';
  46.  
  47. $e_body = "You have been contacted by $name from your contact form, their additional message is as follows." . "\r\n" . "\r\n";
  48.  
  49. $e_content = "\"$comments\"" . "\r\n" . "\r\n";
  50.  
  51. $e_reply = "You can contact $name via email, $email or via phone $phone";
  52.  
  53. $msg = wordwrap( $e_body . $e_content . $e_reply, 70 );
  54.  
  55. $headers = "From: $email" . "\r\n";
  56.  
  57. $headers .= "Reply-To: $email" . "\r\n";
  58.  
  59. $headers .= "MIME-Version: 1.0" . "\r\n";
  60.  
  61. $headers .= "Content-type: text/plain; charset=utf-8" . "\r\n";
  62.  
  63. $headers .= "Content-Transfer-Encoding: quoted-printable" . "\r\n";
  64.  
  65. if(mail($address, $e_subject, $msg, $headers)) { echo "<fieldset><div id='success_page'><h4>Email Sent Successfully.</h4><p>Thank you $name, your message has been submitted to us.</p></div></fieldset>"; }
Go to the top of the page
+Quote Post

Posty w temacie


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: 25.12.2025 - 10:43