Gossamer Forum
Home : Products : DBMan : Customization :

Escaping db.cgi with a couple of strings for php

Quote Reply
Escaping db.cgi with a couple of strings for php
Is it possible to esacpe from db.cgi, after having just logged in as a new user(assuming success), before it takes you off to &html_signup_success, to go to an index2.php page, with the strings for userid and password(pw) carried with you to pick up on in the php page?

I hope this makes sense. I am just starting to learn php, and have got a little bit of the perl sussed, but boy am I a novice here!!.

If you go to www.jagar.co.uk, you can hopefully see the type of thing that I am trying to get. I want to have one site log on, using the dbman log on and one common password system, and then use a menu page which allows you to go and search the variety of databases which will be on the site on one login, insted of doing it seperately each time.

Any help would be gratefully appreicted.

Note: I have got it working like I want, but am having to rely on creatiing a zero second redirect page in the &html_signup_success coding, and I just wanted to avoid that and go straight to the page if possible.

Quote Reply
Re: Escaping db.cgi with a couple of strings for php In reply to
You can use

print "Location:http://url/to/other/page.php\n\n".



JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Escaping db.cgi with a couple of strings for php In reply to
Thanks JP,
I'll give it a try.

Cheers - Rick

Quote Reply
Re: Escaping db.cgi with a couple of strings for php In reply to
Thanks JP

I had to add the following :-


$userid=$in{'userid'};
$pw=$in{'pw'};

(guessed this by looking at other bits of the script - I don't really understand how they work?)

in order to successfully take the userid and passowrd strings with me to the PHP3 page. But having added these two, and putting in your code (adapted to carry the strings as shownbelow),

print "Location:http://www.jagar.co.uk/index2.php3?userid=$userid&pw=$pw\n\n"

it worked a treat!!

Cheers - Rick

(For those who are interested the full amended sub signup is below:-)

sub signup {
# --------------------------------------------------------
# Allows a user to sign up without admin approval. Must have $auth_signup = 1
# set. The user gets @default_permissions.
#
my $message;

# Check to make sure userid is ok, pw ok, and userid is unique.
unless ((length($in{'userid'}) >= 3) and (length($in{'userid'}) <= 12) and ($in{'userid'} =~ /^[a-zA-Z0-9]+$/)) {
$message = "Invalid userid: $in{'userid'}. Must only contain only letters and be less then 12 and greater then 3 characters.";
}
unless ((length($in{'pw'}) >= 3) and (length($in{'pw'}) <= 12)) {
$message = "Invalid pw: '$in{'pw'}'. Must be less then 12 and greater then 3 characters.";
}
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1); }
while (<PASS>) {
/^\Q$in{'userid'}\E:/ and ($message = "userid already exists. Please try another.");
}
close PASS;
if ($message) {
&html_signup_form ($message);
return;
}

# Add the userid into the file with default permissions.
open (PASS, ">>$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($in{'pw'}, $salt);
my $permissions = join (":", @auth_signup_permissions);

print PASS "$in{'userid'}:$encrypted:$permissions\n";
close PASS;

$userid=$in{'userid'}; #added by RP to carry the userid and pw to the next page, to then carry on to the php pagewhich indexes the jagar site
$pw=$in{'pw'}; #added by RP to carry the userid and pw to the next page, to then carry on to the php pagewhich indexes the jagar site

#&html_signup_success; #commented out from the original because instead of going to the config file for this to confirm creation of
#account and log in, I have done it by carrying the userid and password to a php3 file, and then taking the password and userid from
#there to the db.cgi file when they choose what they want to browse. RP

print "Location:http://www.jagar.co.uk/index2.php3?userid=$userid&pw=$pw\n\n" #added by RP from JP's response
}