> Wouldn't it be nice to pass parameters to an SSI
> directive, so that (for example) one could print, say only the contacts for
> december, like so:
> 
>     Apache: <!--#include virtual="/cgi-bin/contacts.cgi?month=12"-->

This is way off topic, but the answer is "you can".  I've checked my IIS and
Apache installations and it works for both of them using the following code:

<html>
<head><title>SSI Test (Apache)</title></head>
<body>
        <P>SSI Test 1:</P>
        <!--#include virtual="/cgi-bin/simple.cgi" -->
        <P>SSI Test 2:</P>
        <!--#include virtual="/cgi-bin/simple.cgi?value=Simon%20Oliver" -->
</body>
</html>

And here's the backend script:

#!perl -Tw
use strict;
use DBI;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

my ($dbd, $dsn, $dbh, $sth, $sql);           
my ($id, $email, $name);
my ($form, @values, $field, $query_op, $logic_op);

$form = new CGI;
@values   = $form->param('value');
$field    = 'name';
$query_op = 'LIKE';
$logic_op = 'OR';

$dbd = 'ODBC'; 
$dsn = 'database';
$dsn = 'contacts';
$dbh = DBI->connect("dbi:$dbd:$dsn");

$sql = 'SELECT contact_id, email, name FROM contact';
if (@values) { 
        $sql .= ' WHERE' . join(" $logic_op", map { " $field $query_op ?" }
@values);
}

$sth = $dbh->prepare($sql); 
$sth->execute(@values);
$sth->bind_columns(\($id, $email, $name));

print qq(Content-Type: text/html\n\n);
print qq(<TABLE>);
print << "EOHTML" while ($sth->fetch);
<TR>
    <TD><A HREF="mailto:$email";><IMG SRC="/images/email.gif" BORDER="0"
ALT="email"></A></TD>
    <TD><A HREF="/cgi-bin/details.cgi?id=$id">$name</A></FONT></CODE></TD>
</TR>
EOHTML
print "</TABLE>";

$dbh->disconnect;

Reply via email to