Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Formularz kontaktowy - z jakiego IP przyszedl mail?
Forum PHP.pl > Forum > Przedszkole
troydon
Witam,
Chce wstawic formularz kontaktowy na moja strone, znalazlem juz gotowy szablon, wszystko dziala, ale brakuje mi jeszcze opcji pokazywania IP lub hosta, z jakiego przyszla wiadomosc.
Jak dodac taka opcje?
Z gory dzieki za pomoc.

Gdzies w necie zlalazlem takie cos:
  1. $body = 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";

Ale gdzie to wkleic?

Ponizej wklejam kod mojego formularza:

  1. <?php
  2. # You can use this script to submit your forms or to receive orders by email.
  3. $MailToAddress = "mail@mail.pl"; // your email address
  4. $redirectURL = "http://strona.pl/"; // the URL of the thank you page.
  5.  
  6. # optional settings
  7. $MailSubject = "Wiadomość z formularza kontaktowego"; // the subject of the email
  8. $MailToCC = ""; // CC (carbon copy) also send the email to this address (leave empty if you don't use it)
  9. # in the $MailToCC field you can have more then one e-mail address like "a@yoursite.com, b@yoursite.com, c@yoursite.com"
  10.  
  11. # If you are asking for a name and an email address in your form, you can name the input fields "name" and "email".
  12. # If you do this, the message will apear to come from that email address and you can simply click the reply button to answer it.
  13.  
  14. # If you have a multiple selection box or multiple checkboxes, you MUST name the multiple list box or checkbox as "name[]" instead of just "name"
  15. # you must also add "multiple" at the end of the tag like this: <select name="myselectname[]" multiple>
  16. # you have to do the same with checkboxes
  17.  
  18. # This script was written by George A. & Calin S. from Web4Future.com
  19. # There are no copyrights in the sent emails.
  20.  
  21. # SPAMASSASSIN RATING: 0.4
  22.  
  23. # DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ===================================================
  24. # ver. 1.6.2
  25. if (preg_match ("/".$_SERVER["SERVER_NAME"]."/i", $_SERVER["HTTP_REFERER"])) {
  26. $w4fMessage = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body>";
  27. if (count($_GET) >0) {
  28. reset($_GET);
  29. while(list($key, $val) = each($_GET)) {
  30. $GLOBALS[$key] = $val;
  31. if (is_array($val)) {
  32. $w4fMessage .= "<b>$key:</b> ";
  33. foreach ($val as $vala) {
  34. $vala =stripslashes($vala);
  35. $w4fMessage .= "$vala, ";
  36. }
  37. $w4fMessage .= "<br>";
  38. }
  39. else {
  40. $val = stripslashes($val);
  41. if (($key == "Submit") || ($key == "submit")) { }
  42. else { if ($val == "") { $w4fMessage .= "$key: - <br>"; }
  43. else { $w4fMessage .= "<b>$key:</b> $val<br>"; }
  44. }
  45. }
  46. } // end while
  47. }//end if
  48. else {
  49. reset($_POST);
  50. while(list($key, $val) = each($_POST)) {
  51. $GLOBALS[$key] = $val;
  52. if (is_array($val)) {
  53. $w4fMessage .= "<b>$key:</b> ";
  54. foreach ($val as $vala) {
  55. $vala =stripslashes($vala);
  56. $w4fMessage .= "$vala, ";
  57. }
  58. $w4fMessage .= "<br>";
  59. }
  60. else {
  61. $val = stripslashes($val);
  62. if (($key == "Submit") || ($key == "submit")) { }
  63. else { if ($val == "") { $w4fMessage .= "$key: - <br>"; }
  64. else { $w4fMessage .= "<b>$key:</b> $val<br>"; }
  65. }
  66. }
  67. } // end while
  68. }//end else
  69. $w4fMessage = "<font face=verdana size=2>".$w4fMessage."</font></body></html>";
  70. if (!$email) {$email = "server@site.com";}
  71. if (!mail($MailToAddress, $MailSubject, $w4fMessage, "From: $name <$email>\r\nReply-To: $name <$email>\r\nMessage-ID: <". md5(rand()."".time()) ."@". ereg_replace("www.","",$_SERVER["SERVER_NAME"]) .">\r\nMIME-Version: 1.0\r\nX-Priority: 3\r\nX-Mailer: PHP/" . phpversion()."\r\nX-MimeOLE: Produced By Web4Future Easiest Form2Mail v1.5\r\nBCc: $MailToCC\r\nContent-Type: text/html; charset=ISO-8859-1\r\nContent-Transfer-Encoding: 8bit\r\n")) { echo "Error sending e-mail!";}
  72. else { header("Location: ".$redirectURL); }
  73. } else { echo "<center><font face=verdana size=3 color=red><b>ILLEGAL EXECUTION DETECTED!</b></font></center>";}
  74. ?>
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
abort
Przy Twojej wiedzy, to jak będziesz chciał to wrzucić w treść maila, to będziesz się musiał lekko napocić. Najprościej to wrzuć to do tematu. Przy okazji masz tę zaletę, że każdy program pocztowy umie np, filtrować po polu tematu maila, więc możesz kiedyś chcieć zrobić z tego użytek. A kod? Najprościej jak się da:
  1. $MailSubject = "Wiadomość z formularza kontaktowego, IP:" . $_SERVER['REMOTE_ADDR'];

troydon
Dzieki bardzo, szybka i trafna odpowiedz, dziala ;-)

Przy okazji jeszcze jedno pytanie:

Czy w tym formularzu mozna dodac opcje "zalacz plik"? Tzn. aby wypelniajacy formularz mogl zalaczyc do wiadomosci np. plik .jpg ?

Pozdrawiam!
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.