Forum Moderators: coopster & phranque

Message Too Old, No Replies

Question on calling a CGI from an SSI

Passing parameters... sort of

         

runner

11:17 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



I have a web page named news.shtml which contains several SSI includes. One of the includes calls the cgi script news.cgi.

News.cgi generates a nicely formatted news article which can be included into a web page. You just have to pass it the news article number so it can look it up in the news database and get the data.

Pretty basic stuff so far. Here's the hard part... I want to create a totally separate page that contains ten links to ten specific news articles. How can I craft the links so that they all point to news.shtml and news.shtml in turn passes a specific article number to the news.cgi script?

I need some way to get the specific news article number to news.cgi. The only way I can think of is to have the link point to some javascript code (I know this isn't the javascript forum) that set a cookie containing the news article number and then jumps to news.shtml. I can then modify the news.cgi to get the news article number from the cookie.

I'd like to know if there's another way to do this without using cookies (although cookies will wotk), maybe by somehow passing the parameter in the link itself.

KevinADC

12:30 am on Aug 23, 2005 (gmt 0)

10+ Year Member



you can pass arguments to cgi scripts in SSI tags:

<!--#include virtual="news.cgi?article=1" -->

you just need to know the correct names and values that you can send to the script for it to work

runner

2:23 am on Aug 23, 2005 (gmt 0)

10+ Year Member



That would work if I only wanted article #1 all the time. If I did it this way, I'd have to create a .shtml file for every article in the database. That defeats the purpose of the include. I'd be better off making static pages for each article.

I need a way to use only one news.shtml file to access all the articles and pass the parameter to the cgi script without putting it in the "include" tag.

KevinADC

2:49 am on Aug 23, 2005 (gmt 0)

10+ Year Member



sorry, my post was just meant to stimulate ideas, in case you didn't know you could pass query string arguments in the SSI tag, not so much as a specific solution. I should have made that clear in my post.

runner

7:04 pm on Aug 23, 2005 (gmt 0)

10+ Year Member



Thanks for the info KevinADC... I'm going to go ahead and use the cookies option though.