Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Problem z kodem do rekomendacji
Forum PHP.pl > Forum > Przedszkole
-kobi-
Witam

moze mi ktos pomoze mam takie dwa skrypty kture działac działaja ale wywalają błedy i niewiem jak to naprawic.

oto index.php
  1. <?php
  2. require('tell_includes.php');
  3. <html>
  4. <head>
  5. <title>Tell-A-Friend</title>
  6. </head>
  7. <body>
  8. <hr>
  9. <?php
  10.  
  11. if ($_GET['to_do']){
  12. $to_do = $_GET['to_do'];
  13. }
  14. elseif ($_POST['to_do']){
  15. $to_do = $_POST['to_do'];
  16. }
  17. else {
  18. $to_do = "first";
  19. }
  20.  
  21. switch ($to_do) {
  22.  
  23. case "first":
  24.  
  25. $url = getenv("HTTP_REFERER");
  26.  
  27. if (!$url){
  28. $url = $default_url;
  29. }
  30.  
  31. echo"<p align='center' style='font-size: 14pt; font-family: $font_face; font-weight: bold;'>Tell-A-Friend</p>";
  32.  
  33. echo"<p align='center' style='font-size: 14pt; font-family: $font_face; font-style: italic;'>$url</p>";
  34.  
  35. echo"<p align='left' style='font-size: 9pt; font-family: $font_face;'>If you would like to tell a friend about this website, please complete the form below, then click <i>'Tell-A-Friend!'</i>.</p>";
  36.  
  37. tell_form($to_name,$to_email,$from_name,$from_email,$url,$comment);
  38.  
  39. break;
  40.  
  41. case "process":
  42.  
  43. $ip = getenv("REMOTE_ADDR");
  44.  
  45. $to_name = $_POST['to_name'];
  46. $to_email = $_POST['to_email'];
  47. $from_name = $_POST['from_name'];
  48. $from_email = $_POST['from_email'];
  49. $url = $_POST['url'];
  50. $comment = $_POST['comment'];
  51.  
  52. if (!(email_validator($to_email))){
  53. echo"<p align='left' style='font-size: 10pt; font-family: $font_face;'><font color='#FF0000'>Error:</font> Sorry, the e-mail address you entered for your friend is invalid. Please try again, making certain you have entered it correctly.";
  54. tell_form($to_name,$to_email,$from_name,$from_email,$url,$comment);
  55. }
  56. else {
  57. if (!(email_validator($from_email))){
  58. echo"<p align='left' style='font-size: 10pt; font-family: $font_face;'><font color='#FF0000'>Error:</font> Sorry, the e-mail address you entered for yourself is invalid. Please try again, making certain you have entered it correctly.";
  59. tell_form($to_name,$to_email,$from_name,$from_email,$url,$comment);
  60. }
  61. else {
  62. if (!$to_name){
  63. echo"<p align='left' style='font-size: 10pt; font-family: $font_face;'><font color='#FF0000'>Error:</font> Sorry, forgot to enter your friends name. Please try again.";
  64. tell_form($to_name,$to_email,$from_name,$from_email,$url,$comment);
  65. }
  66. else {
  67. if (!$from_name){
  68. echo"<p align='left' style='font-size: 10pt; font-family: $font_face;'><font color='#FF0000'>Error:</font> Sorry, forgot to enter your name. Please try again.";
  69. tell_form($to_name,$to_email,$from_name,$from_email,$url,$comment);
  70. }
  71. else {
  72. if (!$url){
  73. echo"<p align='left' style='font-size: 10pt; font-family: $font_face;'><font color='#FF0000'>Error:</font> Sorry, no URL was specified to e-mail to your friend.";
  74. tell_form($to_name,$to_email,$from_name,$from_email,$url,$comment);
  75. }
  76. else {
  77. if(!do_email($to_name,$to_email,$from_name,$from_email,$url,$comment,$ip)){
  78. echo"<p align='left' style='font-size: 10pt; font-family: $font_face;'><font color='#FF0000'>Error:</font> Sorry, there was an error when trying to e-mail your friend. Please try again later.";
  79. tell_form($to_name,$to_email,$from_name,$from_email,$url,$comment);
  80. }
  81. else {
  82.  
  83. echo"<p align='center' style='font-size: 14pt; font-family: $font_face; font-weight: bold;'>E-Mail Sent</p>";
  84.  
  85. echo"<p align='left' style='font-size: 9pt; font-family: $font_face;'>An e-mail has been sent to <b>$to_email</b> with the information you just entered.<br><br><a href='$url'>Click here</a> to go back to the website you recommended.</p>";
  86.  
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
  93. break;
  94.  
  95. case "version":
  96.  
  97. echo"<p align='left' style='font-size: 9pt; font-family: $font_face;'>You are currently using version <b>$version</b> of the Starsol Tell-A-Friend script. The latest version may be downloaded for free at <a href='http://www.starsol.co.uk/scripts/' target='_blank'>Starsol Scripts</a>.</p>";
  98.  
  99. break;
  100.  
  101. }
  102.  
  103. echo"<p align='center' style='font-size: 8pt; font-family: $font_face; color: #888888'>Powered by <a href='http://www.starsol.co.uk/scripts/' target='_blank'>Starsol</a> Tell-A-Friend version $version.</p>";
  104.  
  105. ?>
  106.  
  107. <hr>
  108.  
  109. </body>
  110. </html>
  111.  
  112. <?php // AND THIS LINE ?>

ten skrypt wywala mi cos takiego

Notice: Undefined index: to_do in /home/compart1/public_html/pruba/tell.php on line 38 Notice: Undefined index: to_do in /home/compart1/public_html/pruba/tell.php on line 41
Notice: Undefined variable: to_name in /home/compart1/public_html/pruba/tell.php on line 64 Notice: Undefined variable: to_email in /home/compart1/public_html/pruba/tell.php on line 64 Notice: Undefined variable: from_name in /home/compart1/public_html/pruba/tell.php on line 64 Notice: Undefined variable: from_email in /home/compart1/public_html/pruba/tell.php on line 64 Notice: Undefined variable: comment in /home/compart1/public_html/pruba/tell.php on line 64

teraz tell_includes.php

  1. <?php
  2.  
  3. $font_face = "Verdana,Arial";
  4.  
  5. $default_url = "http://www.starsol.co.uk/scripts/";
  6.  
  7. $starsol_credit = "1";
  8.  
  9. $show_ip = "1";
  10.  
  11. function do_email($to_name,$to_email,$from_name,$from_email,$url,$comment,$ip){
  12.  
  13. global $starsol_credit, $show_ip;
  14.  
  15. $message = "$from_name ($from_email) visited the following website and thought it may be of interest to you:\n\n$url\n\n";
  16.  
  17. if ($comment != ""){
  18. $message = $message . "$from_name also said:\n$comment\n\n";
  19. }
  20.  
  21. if ($show_ip == "1" OR $show_ip == "2"){
  22. if ($show_ip == "1"){
  23. $ip = asterisk_ip($ip);
  24. }
  25. $message = $message . "The IP address for the person who sent this note was $ip.\n\n";
  26. }
  27.  
  28. if ($starsol_credit == "1"){
  29. $message = $message . "~~~~~\nTell-a-friend script powered by Starsol Scripts.\nhttp://www.starsol.co.uk/scripts/";
  30. }
  31.  
  32. if(!mail("$to_email","$to_name, A recommendation from $from_name","$message","FROM:$from_email")){
  33. return FALSE;
  34. }
  35. else {
  36. return TRUE;
  37. }
  38.  
  39. }
  40.  
  41. function email_validator($email_address){
  42. if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email_address)) {
  43. return TRUE;
  44. }
  45. else {
  46. return FALSE;
  47. }
  48. }
  49.  
  50. function asterisk_ip($ip){
  51.  
  52. $ip_fragments = explode(".", $ip);
  53. $ip_fragments[3] = "***";
  54. $ip = "$ip_fragments[0].$ip_fragments[1].$ip_fragments[2].$ip_fragments[3]";
  55.  
  56. return $ip;
  57. }
  58.  
  59. function tell_form($to_name,$to_email,$from_name,$from_email,$url,$comment){
  60.  
  61. global $font_face;
  62.  
  63. echo"<form action='tell.php' method='post'>";
  64. echo"<input type='hidden' name='to_do' value='process'>";
  65. echo"<input type='hidden' name='url' value='$url'>";
  66. echo"<font style='font-size: 9pt; font-family: $font_face;'>";
  67. echo"Friend's Name<br><input type='text' name='to_name' value='$to_name' size='30'><br><br>";
  68. echo"Friend's E-Mail<br><input type='text' name='to_email' value='$to_email' size='30'><br><br>";
  69. echo"Your Name<br><input type='text' name='from_name' value='$from_name' size='30'><br><br>";
  70. echo"Your E-Mail<br><input type='text' name='from_email' value='$from_email' size='30'><br><br>";
  71. echo"Any other comments you would like to send to your friend:<br><textarea name='comment' cols='35' rows='8'>$comment</textarea><br><br>";
  72. echo"<input type='submit' value='Tell A Friend!'>";
  73. echo"</font>";
  74. echo"</form>";
  75. }
  76.  
  77.  
  78. $version = "1.01";
  79.  
  80. ?>


i to mi wywala cos takiego

Notice: Undefined index: to_do in /home/compart1/public_html/pruba/tell.php on line 38

juz niewiem co z tym zrobic prosze o pomoc
-uki-
  1. if (isset($_GET['to_do'])){
  2. if ($_GET['to_do']){
  3.  
  4. $to_do = $_GET['to_do'];
  5.  
  6. }
  7. elseif ($_POST['to_do']){
  8.  
  9. $to_do = $_POST['to_do'];
  10.  
  11. }
  12. }
  13. else {
  14. $to_do = "first";
  15. }
-uki-
Maly blad wink.gif

  1. if (isset($_GET['to_do'])) {
  2. $to_do = $_GET['to_do'];
  3. }
  4. elseif (isset($_POST['to_do'])){
  5. $to_do = $_POST['to_do'];
  6. }
  7. else {
  8. $to_do = "first";
  9. }
-kobi-
witaj

pomogło ale nie do konica

bo nadal zostaje

Notice: Undefined variable: to_name in /home/compart1/public_html/pruba/tell.php on line 64 Notice: Undefined variable: to_email in /home/compart1/public_html/pruba/tell.php on line 64 Notice: Undefined variable: from_name in /home/compart1/public_html/pruba/tell.php on line 64 Notice: Undefined variable: from_email in /home/compart1/public_html/pruba/tell.php on line 64 Notice: Undefined variable: comment in /home/compart1/public_html/pruba/tell.php on line 64
krzywy36
to są tylko notice'y, wyłącz wyświetlanie wszystkich błędów i znikną.

Jeśli nie chcesz, żeby kod generował takie błędy to sprawdzaj zmienne za pomocą isset() przed użyciem.
adri
Cytat(krzywy36 @ 24.06.2012, 18:55:40 ) *
to są tylko notice'y, wyłącz wyświetlanie wszystkich błędów i znikną.

Jeśli nie chcesz, żeby kod generował takie błędy to sprawdzaj zmienne za pomocą isset() przed użyciem.


dodałem
ini_set('display_errors', 1);
error_reporting(E_ALL);
i dalej wyswietla błąd

Deprecated: Function eregi() is deprecated in /home/compart1/public_html/pruba/tell_includes.php on line 86 Deprecated: Function eregi() is deprecated in /home/compart1/public_html/pruba/tell_includes.php on line 86
!*!
Błędów się nie wyłącza, tylko eliminuje. Komunikat błędu jest dość jasny. Napisz ten skrypt poprawnie, eregi zamień na pregi.
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.