|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
OO Perl Question
Hey,
I made a log in script and when someone hits a form I want them to goto another script. The problem is how do I pass the name varaible from the login script onto the new script? Do I have to use a hidden form? Does the only way to do this require cookies? I'd prefer another method. Thanks a lot. |
|
#2
|
|||
|
|||
|
You need to expand on exactly what it is you are trying to do.
If you just want to send them to another script once they are logged in them simply do something like this: print "Location: http://www.yourserver.com/cgi-bin/2ndscript.pl?var=$varvalue\n\n"; What that will do is once your first script is done it will redirect them to a second script and pass whatever $varvalue is equal to in the query string. In your 2nd script to grab the value of $varvalue you would do this: Code:
if ($ENV{QUERY_STRING}) {
$qstring = $ENV{QUERY_STRING};
($var, $varvalue) = split(/=/, $qstring);
}
else {
print "Content-Type: text/html\n\n";
print "Invalid request.\n You must Login first.\n";
exit();
}
I'm not sure if this is what you are trying to do since you were very vague, and why does your subject say OO perl question? You are not asking a question about object oriented programming. Hope this helps!
__________________
"Mankind cannot define memory, yet it defines mankind" |
|
#3
|
|||
|
|||
|
Well, I want someone to login first (login script) and then it'll print out some information from a database and they can edit it. If they hit the edit button, the program needs to know from what table (the login name) and make sure they are logged in. But I don't want it to show the password in the query string. So I prefer post.
Is that enough info. ![]() oh and I said OO because I thought you'd have to do it by creating a module or something along those lines... |
|
#4
|
|||
|
|||
|
Ok
I think I understand a little better now. So basically you need to pass sensitive information from one script to another. There is no real secure way to do this but if you wish to pass it in POST you can do the following. Click the link below to go and read up on LWP. http://www.perldoc.com/perl5.6/lib/lwpcook.html LWP allows perl to act like a web browser and send a request to a web page or perl script and then it gets a response back. I have used it to do some pretty cool stuff before. What you would do is let them login and view their information to edit. Then once they hit the submit button to make changes you would do the following: Code:
use LWP::UserAgent;
$ua = new LWP::UserAgent;
my $req = new HTTP::Request 'POST','http://www.yourserver.com/cgi-bin/perlscript.pl';
$req->content_type('application/x-www-form-urlencoded');
$req->content('username=$username&password=$password&addtionalinfo=1');
my $res = $ua->request($req);
print $res->as_string;
You would change the url of the perl script along with the line that has $req->content('username=$username..... with whatever you want to pass to the 2nd script. Note: This would not be very good at all with a high traffic site. If it is high traffic you might be better off making your own php authentication script or something along those lines. hope that helps. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > OO Perl Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|