Script CGI ne fonctionne pas.

  • ajdegans
  • Born
  • Born
  • No Avatar
  • Inscription: Sep 17, 2003
  • Messages: 4
  • Loc: netherlands
  • Status: Offline

Message Septembre 17th, 2003, 3:54 pm

Salut, im relativement nouveau pour les scripts CGI. J'ai donc pris certaines parties du code et des formulaires créés par e-mail.

On travaille! Mais la seconde ne fonctionnera pas. du CGI ci-dessous ce que ce fichier particulier:

Code: [ Select ]
#!/usr/bin/perl
$sendmail_location = "/usr/sbin/sendmail";

read(STDIN, $formbuffer, $ENV{'CONTENT_LENGTH'});
@formpairs = split(/&/, $formbuffer);
foreach $formpair (@formpairs) {
    ($formname, $formvalue) = split(/=/, $formpair);
    $formvalue =~ tr/+/ /;
    $formvalue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex())/eg;
  $formvalue =~ s/<([^>]|\n)*>//g;
    if ($FORM{$formname}) { $FORM{$formname} = $FORM{$formname}.",".$formvalue; }
    else { $FORM{$formname} = $formvalue; }
}


foreach $require (split(/\,/,$FORM{'require'})) {
if ($require eq "email" || $require eq "to") {
unless ($FORM{$require}=~ /\@/ && $FORM{$require}=~ /\./) {
$error .= "Error in $require.<BR>";
}
}
unless ($FORM{$require}) {
$error .= "Missing $require.<BR>";
}
}

unless ($FORM{'sendpage'}) {
$error .= "Missing confirmation page url<BR>";
}

if ($error) {
print "Content-type: text/html\n\n";
print qq(<CENTER><FONT COLOR="#000000"><B>Error</B><BR>-------------------------<BR>$error</FONT></CENTER>);
exit;
}

if ($FORM{'jounaam'}) {
$yeshow = qq(
Naam, $FORM{'jounaam'}
);
}

if ($FORM{'pakket'}) {
$yeshow = qq(
Pakket, $FORM{'pakket'}
);
}

if ($FORM{'email'}) {
$yeshow = qq(
E-mail, $FORM{'email'}
);
}

if ($FORM{'adres'}) {
$yeshow = qq(
Adres, $FORM{'adres'}
);
}

if ($FORM{'postcode'}) {
$yeshow = qq(
Postcode, $FORM{'postcode'}
);
}

if ($FORM{'plaats'}) {
$yeshow = qq(
Plaats, $FORM{'plaats'}
);
}

if ($FORM{'land'}) {
$yeshow = qq(
Land, $FORM{'land'}
);
}

if ($FORM{'telefoon'}) {
$yeshow = qq(
Telefoon, $FORM{'telefoon'}
);
}

if ($FORM{'gsm'}) {
$yeshow = qq(
gsm, $FORM{'gsm'}
);
}

if ($FORM{'message'}) {
$yeshow = qw(
From, $FORM{'message'}
);
}

if ($FORM{'hoekomjehier'}) {
$yeshow = qq(
Hoe kom je hier, $FORM{'hoekomjehier'}
);
}

open (MAIL, "|$sendmail_location -t") || die "Can't open $sendmail_location!\n";
print MAIL "From: $FORM{'jounaam'} <$FORM{'email'}>\n";
print MAIL "To: $FORM{'to'}\n";
print MAIL "Subject: $FORM{'subject'}\n\n";
print MAIL <<EOF;
$yeshow

$FORM{'message'}


EOF
close (MAIL);

print "Location: $FORM{'sendpage'}\n\n";
exit;
  1. #!/usr/bin/perl
  2. $sendmail_location = "/usr/sbin/sendmail";
  3. read(STDIN, $formbuffer, $ENV{'CONTENT_LENGTH'});
  4. @formpairs = split(/&/, $formbuffer);
  5. foreach $formpair (@formpairs) {
  6.     ($formname, $formvalue) = split(/=/, $formpair);
  7.     $formvalue =~ tr/+/ /;
  8.     $formvalue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex())/eg;
  9.   $formvalue =~ s/<([^>]|\n)*>//g;
  10.     if ($FORM{$formname}) { $FORM{$formname} = $FORM{$formname}.",".$formvalue; }
  11.     else { $FORM{$formname} = $formvalue; }
  12. }
  13. foreach $require (split(/\,/,$FORM{'require'})) {
  14. if ($require eq "email" || $require eq "to") {
  15. unless ($FORM{$require}=~ /\@/ && $FORM{$require}=~ /\./) {
  16. $error .= "Error in $require.<BR>";
  17. }
  18. }
  19. unless ($FORM{$require}) {
  20. $error .= "Missing $require.<BR>";
  21. }
  22. }
  23. unless ($FORM{'sendpage'}) {
  24. $error .= "Missing confirmation page url<BR>";
  25. }
  26. if ($error) {
  27. print "Content-type: text/html\n\n";
  28. print qq(<CENTER><FONT COLOR="#000000"><B>Error</B><BR>-------------------------<BR>$error</FONT></CENTER>);
  29. exit;
  30. }
  31. if ($FORM{'jounaam'}) {
  32. $yeshow = qq(
  33. Naam, $FORM{'jounaam'}
  34. );
  35. }
  36. if ($FORM{'pakket'}) {
  37. $yeshow = qq(
  38. Pakket, $FORM{'pakket'}
  39. );
  40. }
  41. if ($FORM{'email'}) {
  42. $yeshow = qq(
  43. E-mail, $FORM{'email'}
  44. );
  45. }
  46. if ($FORM{'adres'}) {
  47. $yeshow = qq(
  48. Adres, $FORM{'adres'}
  49. );
  50. }
  51. if ($FORM{'postcode'}) {
  52. $yeshow = qq(
  53. Postcode, $FORM{'postcode'}
  54. );
  55. }
  56. if ($FORM{'plaats'}) {
  57. $yeshow = qq(
  58. Plaats, $FORM{'plaats'}
  59. );
  60. }
  61. if ($FORM{'land'}) {
  62. $yeshow = qq(
  63. Land, $FORM{'land'}
  64. );
  65. }
  66. if ($FORM{'telefoon'}) {
  67. $yeshow = qq(
  68. Telefoon, $FORM{'telefoon'}
  69. );
  70. }
  71. if ($FORM{'gsm'}) {
  72. $yeshow = qq(
  73. gsm, $FORM{'gsm'}
  74. );
  75. }
  76. if ($FORM{'message'}) {
  77. $yeshow = qw(
  78. From, $FORM{'message'}
  79. );
  80. }
  81. if ($FORM{'hoekomjehier'}) {
  82. $yeshow = qq(
  83. Hoe kom je hier, $FORM{'hoekomjehier'}
  84. );
  85. }
  86. open (MAIL, "|$sendmail_location -t") || die "Can't open $sendmail_location!\n";
  87. print MAIL "From: $FORM{'jounaam'} <$FORM{'email'}>\n";
  88. print MAIL "To: $FORM{'to'}\n";
  89. print MAIL "Subject: $FORM{'subject'}\n\n";
  90. print MAIL <<EOF;
  91. $yeshow
  92. $FORM{'message'}
  93. EOF
  94. close (MAIL);
  95. print "Location: $FORM{'sendpage'}\n\n";
  96. exit;


Peut-être que quelqu'un peut trouver le code erroné. Moi je pense que la partie avec:
Code: [ Select ]
if ($FORM{'jounaam'}) {
$yeshow = qq(
Naam, $FORM{'jounaam'}
);
}

if ($FORM{'pakket'}) {
$yeshow = qq(
Pakket, $FORM{'pakket'}
);
}

if ($FORM{'email'}) {
$yeshow = qq(
E-mail, $FORM{'email'}
);
}

if ($FORM{'adres'}) {
$yeshow = qq(
Adres, $FORM{'adres'}
);
}

if ($FORM{'postcode'}) {
$yeshow = qq(
Postcode, $FORM{'postcode'}
);
}

if ($FORM{'plaats'}) {
$yeshow = qq(
Plaats, $FORM{'plaats'}
);
}

if ($FORM{'land'}) {
$yeshow = qq(
Land, $FORM{'land'}
);
}

if ($FORM{'telefoon'}) {
$yeshow = qq(
Telefoon, $FORM{'telefoon'}
);
}

if ($FORM{'gsm'}) {
$yeshow = qq(
gsm, $FORM{'gsm'}
);
}

if ($FORM{'message'}) {
$yeshow = qw(
From, $FORM{'message'}
);
}

if ($FORM{'hoekomjehier'}) {
$yeshow = qq(
Hoe kom je hier, $FORM{'hoekomjehier'}
);
}
  1. if ($FORM{'jounaam'}) {
  2. $yeshow = qq(
  3. Naam, $FORM{'jounaam'}
  4. );
  5. }
  6. if ($FORM{'pakket'}) {
  7. $yeshow = qq(
  8. Pakket, $FORM{'pakket'}
  9. );
  10. }
  11. if ($FORM{'email'}) {
  12. $yeshow = qq(
  13. E-mail, $FORM{'email'}
  14. );
  15. }
  16. if ($FORM{'adres'}) {
  17. $yeshow = qq(
  18. Adres, $FORM{'adres'}
  19. );
  20. }
  21. if ($FORM{'postcode'}) {
  22. $yeshow = qq(
  23. Postcode, $FORM{'postcode'}
  24. );
  25. }
  26. if ($FORM{'plaats'}) {
  27. $yeshow = qq(
  28. Plaats, $FORM{'plaats'}
  29. );
  30. }
  31. if ($FORM{'land'}) {
  32. $yeshow = qq(
  33. Land, $FORM{'land'}
  34. );
  35. }
  36. if ($FORM{'telefoon'}) {
  37. $yeshow = qq(
  38. Telefoon, $FORM{'telefoon'}
  39. );
  40. }
  41. if ($FORM{'gsm'}) {
  42. $yeshow = qq(
  43. gsm, $FORM{'gsm'}
  44. );
  45. }
  46. if ($FORM{'message'}) {
  47. $yeshow = qw(
  48. From, $FORM{'message'}
  49. );
  50. }
  51. if ($FORM{'hoekomjehier'}) {
  52. $yeshow = qq(
  53. Hoe kom je hier, $FORM{'hoekomjehier'}
  54. );
  55. }


init est la chose la badass mais je n'ai aucune idée de fixer ce gif "alt =":(" title =" Sad "/>

Si quelqu'un pouvait aider à :(

Merci d'avance
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Septembre 17th, 2003, 3:54 pm

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de l’utilisateur
  • Inscription: Déc 20, 2002
  • Messages: 8922
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Message Septembre 17th, 2003, 11:40 pm

Lorsque vous exécutez ce script, vous faire des erreurs? ou qu'est-ce qui ne fonctionne pas?
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • ajdegans
  • Born
  • Born
  • No Avatar
  • Inscription: Sep 17, 2003
  • Messages: 4
  • Loc: netherlands
  • Status: Offline

Message Septembre 18th, 2003, 8:30 am

Je me procurer cette page d'erreur

Code: [ Select ]
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, helpdesk@flexwebhosting.nl and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



--------------------------------------------------------------------------------

Apache/1.3.27 Server at www.zerocom.nl Port 80
  1. Internal Server Error
  2. The server encountered an internal error or misconfiguration and was unable to complete your request.
  3. Please contact the server administrator, helpdesk@flexwebhosting.nl and inform them of the time the error occurred, and anything you might have done that may have caused the error.
  4. More information about this error may be available in the server error log.
  5. --------------------------------------------------------------------------------
  6. Apache/1.3.27 Server at www.zerocom.nl Port 80


Je l'avais en quelque sorte de travail, mais alors tous les champs de formulaire est resté blanc. si l'ensemble du formulaire a été d'aucune utilité...il ne s'est pas présenté dans le courriel. Donc, fondamentalement, il funcioned mais seulement une partie...
  • bestempire
  • Newbie
  • Newbie
  • No Avatar
  • Inscription: Sep 18, 2003
  • Messages: 7
  • Status: Offline

Message Septembre 18th, 2003, 10:17 am

Vérifiez si vous avez correctement CHMODed le fichier et le chemin d'accès à Perl est à droite
  • ajdegans
  • Born
  • Born
  • No Avatar
  • Inscription: Sep 17, 2003
  • Messages: 4
  • Loc: netherlands
  • Status: Offline

Message Septembre 18th, 2003, 11:35 am

i vérifié chmod

sa:-rwxr-xr-x (755)

Dans le manuel d'un autre script, il fonctionne...

En outre, le chemin de perl est correcte :)
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de l’utilisateur
  • Inscription: Déc 20, 2002
  • Messages: 8922
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Message Septembre 18th, 2003, 7:16 pm

Avez-vous accès à votre serveur de log d'erreur? Plus d'information devrait être là que d'expliquer exactement pourquoi il ne fonctionne pas.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • ajdegans
  • Born
  • Born
  • No Avatar
  • Inscription: Sep 17, 2003
  • Messages: 4
  • Loc: netherlands
  • Status: Offline

Message Septembre 19th, 2003, 1:50 pm

J'ai trouvé ça au error_log

Code: [ Select ]
syntax error at bestelformulier.cgi line 97, near ")("
Execution of bestelformulier.cgi aborted due to compilation errors.

[Thu Sep 18 17:19:10 2003] [error] [client 62.131.20.6] Premature end of script headers: /home/virtual/site59/fst/var/www/cgi-bin/bestelformulier.cgi
  1. syntax error at bestelformulier.cgi line 97, near ")("
  2. Execution of bestelformulier.cgi aborted due to compilation errors.
  3. [Thu Sep 18 17:19:10 2003] [error] [client 62.131.20.6] Premature end of script headers: /home/virtual/site59/fst/var/www/cgi-bin/bestelformulier.cgi


Je suppose que j'ai écrit le. cgi tort, mais je n'ai aucune idée whats wrong depuis que je connais à peine cgi...:)

Afficher de l'information

  • Total des messages de ce sujet: 7 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 296 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC