Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Problem z form2mail (błąd skryptu?)
Forum PHP.pl > Forum > Przedszkole
horn31
Witam,
Potrzebuję formularz który wysyłałby mi dane na maila.
Ustawiłem wszystko (przypuszczam że dobrze)
Oto strona z formularzem: http://cyndragossa.herobo.com/form2mail.htm
Po uzupełnieniu pól i kliknięciu submit, wyświetla się komunikat: Parse error: syntax error, unexpected '<' in /home/a8474792/public_html/form2mail.php on line 29
Jako że po kliknięciu w submit strona przechodzi na nastepny plik to oznacza to ze jest błąd w tym pliku w 29 lini czy jak?

Tak wygląda plik który wyświetla błąd:
  1. <?php
  2. # You can use this script to submit your forms or to receive orders by email.
  3. $MailToAddress = "marek@camel.com.pl"; // your email address
  4. $redirectURL = "http://www.web4future.com/thankyou.htm"; // the URL of the thank you page.
  5.  
  6. # optional settings
  7. $MailSubject = "[Dane z rejestracji na konkurs]"; // 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.  
  26. if (preg_match ("/".$_SERVER["SERVER_NAME"]."/i", $_SERVER["HTTP_REFERER"])) {
  27. $w4fMessage = "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  28. "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  29. <html xmlns="http://www.w3c.org/1999/xhtml" xml:lang="en" lang="en">
  30. <head>
  31. <title> Witamy, zarejestruj się!<title>
  32. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" /"</head><body>";
  33. if (count($_GET) >0) {
  34. reset($_GET);
  35. while(list($key, $val) = each($_GET)) {
  36. $GLOBALS[$key] = $val;
  37. if (is_array($val)) {
  38. $w4fMessage .= "<b>$key:</b> ";
  39. foreach ($val as $vala) {
  40. $vala =stripslashes($vala);
  41. $w4fMessage .= "$vala, ";
  42. }
  43. $w4fMessage .= "<br>";
  44. }
  45. else {
  46. $val = stripslashes($val);
  47. if (($key == "Submit") || ($key == "submit")) { }
  48. else { if ($val == "") { $w4fMessage .= "$key: - <br>"; }
  49. else { $w4fMessage .= "<b>$key:</b> $val<br>"; }
  50. }
  51. }
  52. } // end while
  53. }//end if
  54. else {
  55. reset($_POST);
  56. while(list($key, $val) = each($_POST)) {
  57. $GLOBALS[$key] = $val;
  58. if (is_array($val)) {
  59. $w4fMessage .= "<b>$key:</b> ";
  60. foreach ($val as $vala) {
  61. $vala =stripslashes($vala);
  62. $w4fMessage .= "$vala, ";
  63. }
  64. $w4fMessage .= "<br>";
  65. }
  66. else {
  67. $val = stripslashes($val);
  68. if (($key == "Submit") || ($key == "submit")) { }
  69. else { if ($val == "") { $w4fMessage .= "$key: - <br>"; }
  70. else { $w4fMessage .= "<b>$key:</b> $val<br>"; }
  71. }
  72. }
  73. } // end while
  74. }//end else
  75. $w4fMessage = "<font face=verdana size=2>".$w4fMessage."</font></body></html>";
  76. if (!$email) {$email = "server@site.com";}
  77. if (!mail($MailToAddress, $MailSubject, $w4fMessage, "From: $name <$email>\r\nReply-To: $name <$email>\r\nMessage-ID: <". md5(rand()."".time()) ."@". ereg_replace("file:///C:/Documents%20and%20Settings/nFerno/Pulpit/Formularz/form2mail.php","",$_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-2\r\nContent-Transfer-Encoding: 8bit\r\n")) { echo "Error sending e-mail!";}
  78. else { header("Location: ".$redirectURL); }
  79. } else { echo "<center><font face=verdana size=3 color=red><b>ILLEGAL EXECUTION DETECTED!</b></font></center>";}
  80. ?>



CO muszę zmienić w powyższym skrypcie aby działał i wysyłał mi na maila wypełniony formularz?
Proszę o pomoc.
zordon
mieszasz kod html z php. w 29 linii (jak zresztą wynika z komunikatu błędu) zamknij ?> i otwórz <?php w linii 33.
I ściągnij sobie jakiś edytor z kolorowaniem składni i wyswietlaniem bledów składniowych bo coś takiego świeci się na czerwono i widać od razu
horn31
WItam,
Dzięki zordon za rozwiązanie tego problemu, powstawiałem php tam gdzie trzeba i jest ok.
Mam inny problem:
Wyskakuje mi:
if (preg_match ("/".$_SERVER["SERVER_NAME"]."/i", $_SERVER["HTTP_REFERER"])) { $w4fMessage = " "; $w4fMessage = "".$w4fMessage.""; if (!$email) {$email = "server@site.com";} if (!mail($MailToAddress, $MailSubject, $w4fMessage, "From: $name <$email>\r\nReply-To: $name <$email>\r\nMessage-ID: <". md5(rand()."".time()) ."@". ereg_replace("www.cyndragossa.herobo.com","",$_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-2\r\nContent-Transfer-Encoding: 8bit\r\n")) { echo "Error sending e-mail!";} else { header("Location: ".$redirectURL); } } else { echo "
ILLEGAL EXECUTION DETECTED!
";}

Po edycji dzięki wskazówkom zordona plik wygląda:
  1. <?php
  2. # You can use this script to submit your forms or to receive orders by email.
  3. $MailToAddress = "marek@camel.com.pl"; // your email address
  4. $redirectURL = "http://www.web4future.com/thankyou.htm"; // the URL of the thank you page.
  5.  
  6. # optional settings
  7. $MailSubject = "[Dane z rejestracji na konkurs]"; // 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. ?>
  26. if (preg_match ("/".$_SERVER["SERVER_NAME"]."/i", $_SERVER["HTTP_REFERER"])) {
  27. $w4fMessage = "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  28. "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  29. <html xmlns="http://www.w3c.org/1999/xhtml" xml:lang="en" lang="en">
  30. <head>
  31. <title> Witamy, zarejestruj się!<title>
  32. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" /"</head><body>";
  33. <?php
  34. if (count($_GET) >0) {
  35. reset($_GET);
  36. while(list($key, $val) = each($_GET)) {
  37. $GLOBALS[$key] = $val;
  38. if (is_array($val)) {
  39. $w4fMessage .= "<b>$key:</b> ";
  40. foreach ($val as $vala) {
  41. $vala =stripslashes($vala);
  42. $w4fMessage .= "$vala, ";
  43. }
  44. $w4fMessage .= "<br>";
  45. }
  46. else {
  47. $val = stripslashes($val);
  48. if (($key == "Submit") || ($key == "submit")) { }
  49. else { if ($val == "") { $w4fMessage .= "$key: - <br>"; }
  50. else { $w4fMessage .= "<b>$key:</b> $val<br>"; }
  51. }
  52. }
  53. } // end while
  54. }//end if
  55. else {
  56. reset($_POST);
  57. while(list($key, $val) = each($_POST)) {
  58. $GLOBALS[$key] = $val;
  59. if (is_array($val)) {
  60. $w4fMessage .= "<b>$key:</b> ";
  61. foreach ($val as $vala) {
  62. $vala =stripslashes($vala);
  63. $w4fMessage .= "$vala, ";
  64. }
  65. $w4fMessage .= "<br>";
  66. }
  67. else {
  68. $val = stripslashes($val);
  69. if (($key == "Submit") || ($key == "submit")) { }
  70. else { if ($val == "") { $w4fMessage .= "$key: - <br>"; }
  71. else { $w4fMessage .= "<b>$key:</b> $val<br>"; }
  72. }
  73. }
  74. } // end while
  75. }//end else
  76. ?>
  77. $w4fMessage = "<font face=verdana size=2>".$w4fMessage."</font></body></html>";
  78. if (!$email) {$email = "server@site.com";}
  79. if (!mail($MailToAddress, $MailSubject, $w4fMessage, "From: $name <$email>\r\nReply-To: $name <$email>\r\nMessage-ID: <". md5(rand()."".time()) ."@". ereg_replace("www.cyndragossa.herobo.com","",$_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-2\r\nContent-Transfer-Encoding: 8bit\r\n")) { echo "Error sending e-mail!";}
  80. else { header("Location: ".$redirectURL); }
  81. } else { echo "<center><font face=verdana size=3 color=red><b>ILLEGAL EXECUTION DETECTED!</b></font></center>";}
zordon
nie do końca o to chodziło, tu masz poprawny kod:

  1. <?php
  2. # You can use this script to submit your forms or to receive orders by email.
  3. $MailToAddress = "marek@camel.com.pl"; // your email address
  4. $redirectURL = "http://www.web4future.com/thankyou.htm"; // the URL of the thank you page.
  5.  
  6. # optional settings
  7. $MailSubject = "[Dane z rejestracji na konkurs]"; // 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.  
  26. if (preg_match ("/".$_SERVER["SERVER_NAME"]."/i", $_SERVER["HTTP_REFERER"])) {
  27. $w4fMessage = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  28. "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  29. <html xmlns="http://www.w3c.org/1999/xhtml" xml:lang="en" lang="en">
  30. <head>
  31. <title> Witamy, zarejestruj się!<title>
  32. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" /"</head><body>"';
  33.  
  34. if (count($_GET) >0) {
  35. reset($_GET);
  36. while(list($key, $val) = each($_GET)) {
  37. $GLOBALS[$key] = $val;
  38. if (is_array($val)) {
  39. $w4fMessage .= "<b>$key:</b> ";
  40. foreach ($val as $vala) {
  41. $vala =stripslashes($vala);
  42. $w4fMessage .= "$vala, ";
  43. }
  44. $w4fMessage .= "<br>";
  45. }
  46. else {
  47. $val = stripslashes($val);
  48. if (($key == "Submit") || ($key == "submit")) { }
  49. else { if ($val == "") { $w4fMessage .= "$key: - <br>"; }
  50. else { $w4fMessage .= "<b>$key:</b> $val<br>"; }
  51. }
  52. }
  53. } // end while
  54. }//end if
  55. else {
  56. reset($_POST);
  57. while(list($key, $val) = each($_POST)) {
  58. $GLOBALS[$key] = $val;
  59. if (is_array($val)) {
  60. $w4fMessage .= "<b>$key:</b> ";
  61. foreach ($val as $vala) {
  62. $vala =stripslashes($vala);
  63. $w4fMessage .= "$vala, ";
  64. }
  65. $w4fMessage .= "<br>";
  66. }
  67. else {
  68. $val = stripslashes($val);
  69. if (($key == "Submit") || ($key == "submit")) { }
  70. else { if ($val == "") { $w4fMessage .= "$key: - <br>"; }
  71. else { $w4fMessage .= "<b>$key:</b> $val<br>"; }
  72. }
  73. }
  74. } // end while
  75. }//end else
  76.  
  77. $w4fMessage = "<font face=verdana size=2>".$w4fMessage."</font></body></html>";
  78. if (!$email) {$email = "server@site.com";}
  79. if (!mail($MailToAddress, $MailSubject, $w4fMessage, "From: $name <$email>\r\nReply-To: $name <$email>\r\nMessage-ID: <". md5(rand()."".time()) ."@". ereg_replace("www.cyndragossa.herobo.com","",$_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-2\r\nContent-Transfer-Encoding: 8bit\r\n")) { echo "Error sending e-mail!";}
  80. else { header("Location: ".$redirectURL); }
  81. } else { echo "<center><font face=verdana size=3 color=red><b>ILLEGAL EXECUTION DETECTED!</b></font></center>";}


w linii 27 zaczynasz do zmiennej php przypisywać kod html w postaci tekstu, tyle ze w kodzie html masz cudzysłów, który 'kończy' zmienną i powoduje błąd składni php.
Zainstaluj sobie dobry edytor! To Ci zaoszczędzi takich przygód w przyszłości
horn31
Wszystko działa dzięki wielkie!
Napewno skorzystam z Twoich rad kolego.
Jeszcze raz dziękuję i 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.