Gossamer Forum
Home : Products : Links 2.0 : Customization :

Quick gimmicky mod

Quote Reply
Quick gimmicky mod
For those who have .shtml pages (or even just your main page), here is a quick gimmicky mod to show a welcome message to people who have submitted links to your directory before.

In your cgi-bin make a new file called welcome.cgi with this code in it:


Code:
#!/usr/bin/perl
Code:
use CGI qw(:standard);
my $IN = new CGI;
Code:
$val = $IN->cookie('WelcMSG');
Code:
if ($val) {
print "Welcome back $val!";
} else {
print "Welcome Guest!";
}
Then in either home.html or any .shtml page you like add:



<!--#exec cgi="/cgi-bin/welcome.cgi"-->

Then in add.cgi change:

Code:
# Send the visitor to the success page.
&site_html_add_success;
to.....


Code:
# Send the visitor to the success page.
use CGI qw(:standard);
if ($in{'Contact Name'} =~ /\w+\s\w+/) {
split /\s/, $in{'Contact Name'};
$name = $_[0];
} else {
$name = $in{'Contact Name'};
}
$ck = cookie( -name => "WelcMSG",
-value => $name,
-expires => '+5yr',
-domain => ''
);
print header ( -cookie => $ck );
&site_html_add_success;
...then finally in sub site_html_add_success in site_html_templates.pl remove &html_print_headers;

Return visitors will then get a message like "Welcome back Paul"




Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Quick gimmicky mod In reply to
Definatly gimmicky, but overall a good idea and nice mod Wink

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Quick gimmicky mod In reply to
It was due to intense boredom brought about my rain Frown...it's now sunny Smile

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Quick gimmicky mod In reply to
Its alright for some Wink. We still have rain down here in Sussex Frown

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Quick gimmicky mod In reply to
For whatever reason this isn't working. The cookie is being set, the SSI call isn't failing...the direct call to welcome.cgi is, but I assume it should.

Gimmicks are good dontcha know. Any idea why it might not work?

Quote Reply
Re: Quick gimmicky mod In reply to
Is nothing showing?

Is the page .shtml? (sorry not trying to patrronise)

If you added it into home.html you will need to rebuild and make sure $build_index is something like "index.shtml";

Does it work if you go to welcome.cgi directly?

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Quick gimmicky mod In reply to
The page can display SSI (does so with news updates), it's not .shtml though but I have .html parsed via .htaccess so all SSI works.

Going directly (via the web) gives a server error though...but the page doesn't display that there was an error calling the script...(like SSI does...I believe)

Quote Reply
Re: Quick gimmicky mod In reply to
Try adding:

print $IN->header;

just under my $IN = new CGI; and then go directly to it again.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Quick gimmicky mod In reply to
Going directly to it does work after adding that....odd that it isn't showing though. It's obviuosly calling it as it doens't show up in the HTML source of the page....

Wierd.

Quote Reply
Re: Quick gimmicky mod In reply to
Hmm strange....I have it working on one of my sites and it seems to be ok...I haven't had any trouble with it.

I'll try to make a few alterations and re-post the code.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Quick gimmicky mod In reply to
Ok this is the exact code I'm using on my site that works....

Code:
#!/usr/bin/perl

use CGI qw(:standard);
my $IN = new CGI;

print $IN->header;

$val = $IN->cookie('WelcMSG');

if ($val) {
print "Welcome back $val!";
} else {
print "Welcome Guest!"
}
Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Quick gimmicky mod In reply to
This is driving me insane as to why this isn't working. If I call the script directly it works correctly in parsing the cookie. If I call it via SSI the if ($val) fails and displays the false setting. Display $val via the page displays nothing of course.

Any thoughts as to why this specific problem would occur?

Quote Reply
Re: Quick gimmicky mod In reply to
There should be no other reason why it isn't working as that same code is being used on my site in a shtml page and it shows "Welcome Guest!"

If it works going directly to it then the only think I can think of is that SSI isn't working for that page...but as you have SSI news on it then it must be. I'm stuck.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Quick gimmicky mod In reply to
See, the thing now Paul, is that it does display Welcome Guest...but that's all it displays because the if($val) always fails via the page for some reason but directly it doesn't. So odd. But eh, I'll live I spose.

Quote Reply
Re: Quick gimmicky mod In reply to
It could also be a problem with the CGI module version you have installed...some scripts do not function well with legacy versions of CGI.pm. I would recommend checking that version against the current version available at http://www.cpan.org.

I know it is probably a shot in the dark, but I've seen this happen before with older versions of CGI.pm.

Regards,

Eliot Lee Wink
http://anthrotech.com/