Click to See Complete Forum and Search --> : New to CGI- need some help on CGI page


Xeenslayer
03-18-2003, 08:02 PM
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 (http://www.htmlgoodies.com/beyond/placecgi.html#section2). 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 (http://www.caesar3bsc.netfirms.com/gb.html).

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?

Xeenslayer
03-18-2003, 09:07 PM
Oops I managed to find out these questions for myself after reading the primers.

CGI's pretty fun. :)

Xeenslayer
03-19-2003, 04:46 AM
Mmm now I really do need some help... I'm still meddling with that guestbook (here (http://www.caesar3bsc.netfirms.com/gb.html)) 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. :(

DaiWelsh
03-19-2003, 10:02 AM
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

Xeenslayer
03-19-2003, 07:38 PM
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?

DaiWelsh
03-20-2003, 05:33 AM
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

Xeenslayer
03-20-2003, 07:51 AM
Ooops looks like I'm out of practice with CSS for quite a long time too! :D

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