dcsimg
www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: guestbook trouble

  1. #1
    Join Date
    Dec 2002
    Location
    los angeles
    Posts
    137

    guestbook trouble

    I am new to cgi-bin and I am trying to get a guestbook to work that is off of the htmlgoodies tutorials. I have a directory called cgi-bin and I have the guestbook script inside that directory called guestbook.cgi. I also have the html form page saved in the httpdocs directory. Now, when I fill out the form and hit send, I get an internal Error. What it's suppose to do is send to my email.

    Heres the HTML code.


    <HTML>
    <HEAD>
    <TITLE>Guestbook Script</TITLE>

    </HEAD>

    <BODY BGCOLOR="#FFFFFF">

    <FORM METHOD="post" ACTION="/cgi-bin/guestbook.cgi">

    <INPUT NAME="name" SIZE=50 TYPE="text"> <B>Your Name</B><BR>
    <INPUT NAME="email" SIZE=50 TYPE="text"> <B>Your E-Mail Address</B><BR>
    <INPUT TYPE="hidden" NAME="submitaddress" VALUE="brucelee@uogameresources.com">
    <B>Write to me below:</B><P>
    <TEXTAREA NAME="feedback" ROWS=10 COLS=50></TEXTAREA><P>

    <CENTER>
    <INPUT TYPE=submit VALUE="SEND">
    <INPUT TYPE=reset VALUE="CLEAR">
    </CENTER>

    </FORM>

    </BODY>
    </HTML>


    Heres the cgi-bin code


    #!/usr/bin/perl

    # That is the path to PERL just above It MUST be first in the script
    # The following accepts the data from the form

    if ($ENV{'REQUEST_METHOD'} eq 'POST') {

    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

    @pairs = split(/&/, $buffer);

    foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $FORM{$name} = $value;
    }



    # The following sends the email

    open (MESSAGE,"| /usr/lib/sendmail -t");

    print MESSAGE "To: $FORM{submitaddress}\n";
    print MESSAGE "From: $FORM{name}\n";
    print MESSAGE "Reply-To: $FORM{email}\n";

    print MESSAGE "Subject: Feedback from $FORM{name} at $ENV{'REMOTE_HOST'}\n\n";
    print MESSAGE "The user wrote:\n\n";
    print MESSAGE "$FORM{feedback}\n";
    close (MESSAGE);

    &thank_you;
    }




    #The following creates the Thank You page display

    sub thank_you {

    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print "<HEAD>\n";
    print "<TITLE>Thank You!</TITLE>\n";
    print "</HEAD>\n";
    print "<BODY BGCOLOR=#FFFFCC TEXT=#000000>\n";
    print "<H1>Thank You!</H1>\n";
    print "\n";
    print "<P>\n";
    print "<H3>Your feedback is greatly appreciated.<BR>\n";
    print "<P>\n";
    print "</BODY>\n";
    print "</HTML>\n";
    exit(0);
    }

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    I didn't look through any of you code, but one thing you may want to try first is making sure you a) uploaded in ascii, and b) make sure you chmoded your .cgi code.

  3. #3
    Join Date
    Dec 2002
    Location
    los angeles
    Posts
    137
    It did mention in the tutorial to make sure you upload in ascii or a text editer with no margins. I don't know what they ment by all that. All I did was cut/pasted it into notepad then uploaded it using my ftp.

  4. #4
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Your FTP program should have an "upload as ascii" option. Try looking in the help.

  5. #5
    Join Date
    Dec 2002
    Location
    los angeles
    Posts
    137
    I dont see an option to switch to ascii. It's not exactly my ftp, it's avahosts(my hosting providers').

  6. #6
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Well, I can tell you now that it's not going to work until you are able to upload in ascii. I think that you can get a lite (free) version of ws_ftp... Yup... http://www.ipswitch.com/downloads/index.html down by the bottom.

  7. #7
    Join Date
    Dec 2002
    Location
    los angeles
    Posts
    137
    Arigatou gozaimasu! I'm going through the tutorials now.

  8. #8
    Join Date
    Dec 2002
    Location
    los angeles
    Posts
    137
    I learned about ftp and I uploaded the guestbook.cgi file in ascii. I'm still getting an internal error when I try to post something. guest book page If you don't mind, can you try to post something? Maybe you'll know what's wrong after reading the error.

  9. #9
    Join Date
    Jan 2003
    Location
    Atlanta, GA
    Posts
    571
    Make sure that you have set correct permissions.

    Next, try running the cgi from the shell (telnet/SSH into ur account). See if it runs.

    If not, do dos2unix. I dont know what it does, but I needed to do that when I used notepad.

  10. #10
    Join Date
    Jan 2003
    Location
    Atlanta, GA
    Posts
    571
    Another suggestion: use CGI.pm module. It really makes life easy.

  11. #11
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    I took a look at your script, but a 500 Server Error can mean just about anything. That's why I use PHP. Anyway, check to make sure your permissions are set up correctly on guestbook.cgi...It probably needs 755 or 777

  12. #12
    Join Date
    Nov 2002
    Location
    NY, USA
    Posts
    731
    use CGI::Carp 'fatalsToBrowser';

    Use this to display the Perl error message rather than apache's. Though your code compiled fine for me so my guess would be your path to perl is incorrect.

    Running dos2unix and uploading in binary is the same as just uploading as text.
    DOS2UNIX.EXE converts MS-DOS text files to Unix format, by stripping any CR or end-of-file (Ctrl-Z) characters from the data.

  13. #13
    Join Date
    Dec 2002
    Location
    los angeles
    Posts
    137
    Thanks for all the suggestions. Looks like I got a few things to study.

  14. #14
    Join Date
    Dec 2002
    Location
    los angeles
    Posts
    137
    hmm this sucks. I'm reading a tutorial on how to place a cgi script. It says I need to beable to telnet into it. Well after reading the small telnet tutorial, I try to telnet in and it says can't make a connection. Must mean my isp don't allow it? You can do this without telnet, right?

  15. #15
    Join Date
    Dec 2002
    Location
    los angeles
    Posts
    137
    I figured it out. I had the permission set wrong. cgi scripts permission has to have it set at 700.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles