
sleuth
Enthusiast
Nov 30, 2000, 4:21 PM
Post #3 of 3
(678 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).]
|