http://qs321.pair.com?node_id=1186999

jenlear has asked for the wisdom of the Perl Monks concerning the following question:

I have a form that uses send.pl, All I did was go in and change the email addresses that the results should go to, and now it returns a Internal server error. Not sure what to do.

I restored it with a backup and It still returns an error.

I reset the permissions to 644. Still no luck. Anyone able to help?

Part of code changed:

my $emailTo = 'Customer Service <customerservice@df-foods.com>'; my $emailFrom = FilterCChars($FTGEmail); open(MAIL,"|$mailProg"); print MAIL "To: $emailTo\n"; print MAIL 'Cc: Frank Simmons <fsimmons@oregonpotato.com,susan@ftiegs. +com,jenbrink@icloud.com>’ . "\n"; print MAIL "From: $emailFrom\n"; print MAIL "Subject: $emailSubject\n"; print MAIL "Content-Type: text/plain; charset=\"UTF-8\"\n"; print MAIL "Content-Transfer-Encoding: 8bit\n"; print MAIL "\n"; print MAIL $emailBody; close(MAIL); # Redirect user to success page print "Location: /thankyou.html\n\n"; exit;

Replies are listed 'Best First'.
Re: Form Stopped working
by poj (Abbot) on Apr 04, 2017 at 15:22 UTC

    Look very carefully at the quote at the end of this line

    'Cc: Frank Simmons &lt;fsimmons@oregonpotato.com,susan@ftiegs.com,jenbrink@icloud.com>’
    poj
      Ahhhh let me see if it will work now...
      Very nice catch!! Thank you soon much!

        You might consider making the script more consistent with a variable

        my $emailCC = 'Any Person <anyperson@anywhere.com,nobody@nobody.com,so +mebodyelse@icloud.com>'; print MAIL "To: $emailTo\n"; print MAIL "Cc: $emailCC\n"; . .
        poj
      A) Welcome to the monastery, jenlear!
      B) As poj is pointing out, curly quotes (sometimes called "smart quotes") are not the same as straight quotes in Perl. You'll have a lot easier time if you find a programming-oriented text editor program that doesn't change your straight quotes to curly ones. If we knew what OS you were using, maybe we could suggest a good one.

      Nice catch!

Re: Form Stopped working
by kennethk (Abbot) on Apr 04, 2017 at 15:53 UTC
    poj appears to have solved the issue. A comment about form: please note that you did not close your code block (</code>). You avoid a lot of formatting issues if you use properly balanced <code> tags.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: Form Stopped working
by stevieb (Canon) on Apr 04, 2017 at 15:23 UTC

    When the error occurs, what does the web server's log file say about the problem? Almost always, the answer is in the server's error log.

      This only said Internal Server Error, contact administrator about the problem...

      Thats the first thing I look for, a message in the error, but this didn't give any hints.

      "curly" quote killed the script. Typo.

        What happened when you contacted the administrator? On a serious note, the webserver error logs likely contain the relevant information. "All I did was go in and change the email addresses that the results should go to". It's important to be able to limit the scope of what you change, and check that nothing else has been altered by accident. Keeping an original and an edited version, comparing them with diff (or similar tool) is very handy.

        Do you have access to the server command line? You can check the syntax of a script without running it with the -c flag.

        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.