CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
redirection based on login - HELP ME PLEASE

 



kerry
Deleted

Nov 28, 2000, 1:40 PM

Post #1 of 3 (999 views)
redirection based on login - HELP ME PLEASE Can't Post

Hi, im looking for a script to send user to page based on login, it would be nice if it used htaccess (but also great if it doesn't) but if MUST send different users to different pages based on login (prefer just to have either username or password - NOT BOTH)

thanks, any help would be fantastic
PERL FOREVER


sleuth
Enthusiast

Nov 30, 2000, 9:54 AM

Post #2 of 3 (999 views)
Re: redirection based on login - HELP ME PLEASE [In reply to] Can't Post

 
That's easy Don't Panic, I'm stapped for time more than ever though. I'll write it on my LUNCH BREAK, LOL, It's an easy one, should take me 15 min.

Talk soon,

Sleuth


sleuth
Enthusiast

Nov 30, 2000, 4:21 PM

Post #3 of 3 (999 views)
Re: redirection based on login - HELP ME PLEASE [In reply to] Can't Post

 K Kerry, It's finished, Late Lunch, hehe,

Here is the html:

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Redirection</title>
</head>
<body>
<p align="center">Design it *YOURSELF*</p>
<p align="center">Hee hee</p>
<form method="POST" action="http://www.site.com/cgi-bin/redirect.cgi">
<p align="center">User Name: <input type="text" name="user" size="20"></p>
<p align="center"><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>


Here is the CODE:

#!/usr/bin/perl

sub parse_form {
my (@pairs, %in);
my ($buffer, $pair, $name, $value);

if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
else {
&cgierr('You cant run this script from telnet/shell.');
}

PAIR: foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

($value eq "---") and next PAIR;
exists $in{$name} ? ($in{$name} .= "~~$value") : ($in{$name} = $value);
}
return %in;
}
###########################################################
%in =&parse_form;
#########
$pageDB = 'pages.db';
# Name Of Data Base With user Names And Page Names / Urls
$base_url = 'http://';
# this way if you decide you want to put, "http://www.site.com/" >
# in the data base just put the page names, not the whole url.
#########
#print "Content-type: text/html\n\n";
open(data, "<$pageDB");
while(<data> ){
($name, $page)=split(/\|\^\|/, $_);
if ($in{'user'} eq "$name"){
print "Location:$base_url$page\n\n";
$gotit=1;
last;
}
}
close(data);
if (!$gotit){
print "Content-type: text/html\n\n";
print "The User Name \"$in{'user'}\" Was Not Found.";
}
exit;


Here is what the data should look like:

tony|^|www.perlguru.com|^|
bob|^|www.compusa.com|^|

Then just type in the name, bla bla you know :) I can zip it and mail it if it's easier. ??

Sleuth

[This message has been edited by sleuth (edited 11-30-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives