Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI and HTML Link 1

Status
Not open for further replies.

samesale

Programmer
Sep 15, 2003
133
US
I have written the following CGI program. It supposed to allow a user to click on the picture, and the user is shown a picture in a bigger size. However, it goes to cgi directory instead of html, i.e.,


instead of


in which the program is located. When I wrote the same statement in just HTML, it worked. Please help. Thanks.

#!/usr/bin/perl

print "Content-type:text/html\n\n";

use CGI;
$query = new CGI;

$query->header;
print &quot;<html>\n<head>\n<TITLE></TITLE>\n&quot;;
print &quot;</HEAD>\n<BODY>\n&quot;;
print &quot;<A HREF=\&quot;picture.html\&quot;><img src=\&quot;/images/car.jpg\&quot; width=\&quot;100\&quot; height=\&quot;100\&quot; align=\&quot;left\&quot; vspace=\&quot;5\&quot; hspace=\&quot;5\&quot; alt=\&quot;car.jpg\&quot;></A>\n&quot;;
 
print &quot;<A  HREF=\&quot;[red]../[/red]picture.html\&quot;><img src=\&quot;/images/car.jpg\&quot; width=\&quot;100\&quot; height=\&quot;100\&quot; align=\&quot;left\&quot; vspace=\&quot;5\&quot; hspace=\&quot;5\&quot; alt=\&quot;car.jpg\&quot;></A>\n&quot;;


Kind Regards
Duncan
 
Thanks. It worked. How easy it is when one knows. Thanks again.
 
Now, I need help with passing a variable between a CGI program and an HTML program. For example:

print &quot;<A HREF=\&quot;../picture.html\&quot;><img src=\&quot;/images/$tele.jpg\&quot; width=\&quot;100\&quot; height=\&quot;100\&quot; align=\&quot;left\&quot; vspace=\&quot;5\&quot; hspace=\&quot;5\&quot; alt=\&quot;car.jpg\&quot;></A>\n&quot;;

In this program, the varaiable $tele is read in the CGI program and a user can see the picture in the CGI program. However, to expand it, the user clicks the picture and should take it to the HTML to see a larger picture. However, $tele is unknown in the HTML. Is it pssoble to pass the value of $tele to the HTML or is there another way to accomplish the job. Thanks.

 
Write the large image page in cgi as well so that you can easily pass variables between the forms.

IN YOUR THUMBNAIL PAGE: (e.g. thumbs.cgi)
As the link to the large image page write this:
print &quot;<A HREF=\&quot;lrg_img.cgi?tele=$tele\&quot;>Click to view large</A>&quot;;

IN YOUR LARGE IMAGE PAGE: (e.g. lrg_img.cgi)
Then in your recieving page write the following:

use CGI;

$query = new CGI;

my $tele = $query->param('tele');

print &quot;<img src=\&quot;/images/$tele.jpg\&quot;>&quot;;


However if I may say, this is of bad design. The whole point of thumbnails is to send much smaller versions of the main pictures so that the user doesn't have to wait hours to download all the pictures. Your resize of the the image doesn't make the file size smaller, so the user will have to download the entire file before his/her browser resizes it.

I recently completed a image upload webpage like yours. If you like I could send you an example if you like.

P.S. Are you using windows or linux?
 
Sorry, just a note on the following:

IN YOUR THUMBNAIL PAGE: (e.g. thumbs.cgi)
As the link to the large image page write this:
print &quot;<A HREF=\&quot;lrg_img.cgi?tele=$tele\&quot;>Click to view large</A>&quot;;

You can replace &quot;Click to view&quot; with the <IMG...> if you like.
 
Thank you very much sean4e. It worked. I really appreciate your help. Please send me your example. I appreciate your help. Thanks.
 
No problem samesale.

I don't mind helping out or sending you a good example, but in order for me to send it I am gonna have to get some sort of email address ;-)

Are you using windows or linux to code? - This is just so I know exactly which example to send you.
 
sean4e:
I appreciate you helping me. However, I cannot put my e-mail on this page. I do not have any other way to communicate with you. Thanks for your help anyway. I use windows for all my work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top