www.webdeveloper.com
Results 1 to 7 of 7

Thread: New to CGI- need some help on CGI page

  1. #1
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    44

    New to CGI- need some help on CGI page

    Hi all, I just got started with CGI. I started off with the tutorial on CGI here: http://www.htmlgoodies.com/beyond/placecgi.html

    I then proceeded to download the files from here. I modified the CGI file to work on the server.

    The script works, but I need some help on further customizing the file. The link to the HTML page is here.

    After submission, the browser returns me to the CGI page. There is a link "Back" which sends me to my CGI directory. How can I change the script to change the Anchor link? This is the part of the code:

    ______________________________

    }
    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=#FFFFFF TEXT=#000000>\n";
    print "<H1>Thank You!</H1>\n";
    print "\n";
    print "<P>\n";
    print "<H3>Your feedback is greatly appreciated.<BR>\n";
    print "Click here to go <A HREF=$ENV{'REFERRER'}>Back</A>.\n";
    print "<P>\n";
    print "</BODY>\n";
    print "</HTML>\n";
    exit(0);
    }
    ______________________________

    I tried changing the <A HREF=$ENV{'REFERRER'}> part to <A HREF=URI>. It doesn't seem to help.

    Next, this question might sound stupid, but I have no idea where the feedback is sent to. How do I read what my visitors say?

  2. #2
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    44
    Oops I managed to find out these questions for myself after reading the primers.

    CGI's pretty fun.

  3. #3
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    44

    Post

    Mmm now I really do need some help... I'm still meddling with that guestbook (here) and I'm wondering how to change the background of the CGI thank-you page.

    You see, my cgi files are in the directory "cgi-bin" while my other files are in the directory "www". My background image file is sitting inside the "www" directory. How do I put in the code that allows me to get the image there to be used in the cgi file?

    My webhost (Netfirms) tells me that my site document root should be indicated with this: "$ENV{'DOCUMENT_ROOT'}".

    Do I put this in the cgi script?
    _______________

    print "<body style='background:$ENV{DOCUMENT_ROOT}/www/blah.jpg'>
    _______________

    I tried but it didn't work.

  4. #4
    Join Date
    Feb 2003
    Location
    Derby, UK
    Posts
    456
    You should just be able to use

    style='background:/blah.jpg;'

    It is important to distinguish paths that are used by the script while it is running on the server and paths that are used by the browser after the script has finished running and passed its results back to the browser.

    In this case, the browser is going to be the one that goes and finds the background image and as far as the browser is concerned the image is located in the root of your website, as the browser knows nothing about your behind-the-scenes dircetory structure.

    If you were trying to open a file in your www directory from a script running in your cgi-bin directory then you might need to know about the paths, but not for this, at least as it is explained here.

    HTH,

    Dai

  5. #5
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    44
    Mmm no it doesn't work. I tried these, but all failed:

    background:/blah.jpg
    background-image:/blah.jpg
    background:/www/blah.jpg
    background-image:/www/blah.jpg

    I checked to make sure that nothing was wrong with the image name etc. What could have gone wrong?

  6. #6
    Join Date
    Feb 2003
    Location
    Derby, UK
    Posts
    456
    Sorry, my fault, I only checked your path, not the rest of the syntax. The correct syntax is

    style='background: url(/blah.jpg);'

    HTH,

    Dai

  7. #7
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    44
    Ooops looks like I'm out of practice with CSS for quite a long time too!

    Thanks a lot. It worked like a charm. Does that apply to all other files too?

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