Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Users and Passwords

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
Hi, I have made HTML sites, and basic forms to be interpretted and processed by the CGI server. I was just wondering if I could upload a file to the CGI (a list of users, and their corresponding passwords) so that instead of having a VB Script input box, which is blatant to all on the who can just view source. I can pass the value a user inputs in a 'log in' form, to check it against a file on the server. As I only have limited funds, and cannot afford to run my own sever, and own SQL. So if anyone has a clue, I'd be most grateful.
Thanx very much
JOE
joewardell@hotmail.com
 
ok.....how!
I have a list of users and their passwords, but I'm not sure of the Server's CGI capabilities, how would I load a program that could check the users, and their password's.
As I have no clue about CGI whatsoever. Does anyone have a code that would do this.
Thanx
JOE
 
Good Morning Oxymoron,
I think you may be in over you head here..... The 'let me find some code and drop it on a server' approach can be dangerous. I humbly suggest that the only time you should do that is when you can read and make sense of the code and are also aware of the security and performance issues that may exist. A few questions.....

?Do you write any Perl?
?What kind of time line are you on?


>ok.......how!
a not as concise answer as you would like........
About CGI...... CGI is simply a set of rules that defines how to talk to a web server and get it to run a program for you. The code can do anything you want to write it to do. As long as you obey the rules, you can write your code in any language. The subject is to wide and deep to address reasonably via this medium. There are many tutorials on the web to learn some basic Perl and to learn how to use Perl to do CGI. There is a good start at Additionally, Dr. Lincoln Stein has a good security faq at Once you get a handle on Perl and CGI, your problem is pretty straight forward, if not trivial. If this is to much to do, then I suggest you need to get some professional support, or, if this is an assignment, you better get to work.

Good Luck....
Let us know as you run into bumps, and we'll answer any specific questions that you have.




keep the rudder amid ship and beware the odd typo
 
Read some tutorials, go to school, or hire a real web developer.

I'm not going to write a program for you.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Hi
I know I don't have a clue about CGI, I was just intrested as to it's capabilities, I don't want anyone to rite a program for me, I just wanted to learn.
Thanx for all your help.
JOE
 
Here is a short script that I wrote a while back. Just change the data accordingly. It reads from a flat text file that looks something like this:

user1,password1
user2,password2
user3,password3

Save it as data.txt. The txt file must also be comma delimited.

Here is the script. I think that it is pretty self explanatory.

[tt]

#!usr/bin/perl

# location of the txt file
$datadir = "e:\\nameofyourserver\\yoursite.com\\

# collect the data from the user using Post

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

if ($FORM{'action'} eq "checkpassword") { &checkpassword; }
else { &default; }

sub default {
print "Content-type: text/html\n\n";
print &quot;<html>\n<head>\n<title>Enter your user name and Password</title>\n</head>\n&quot;;
print &quot;<body>\n&quot;;
print &quot;<form method=\&quot;post\&quot;>\n&quot;;
print &quot;<input type=\&quot;hidden\&quot; value=\&quot;checkpassword\&quot; name=\&quot;action\&quot;>\n&quot;;
print &quot;<font face=\&quot;verdana\&quot; size=\&quot;-2\&quot; color=\&quot;black\&quot;><b>username:</b></font>\n&quot;;
print &quot;<br><input type=\&quot;text\&quot; name=\&quot;user\&quot; style=\&quot;background:00648E; color:white; height:20; font-size:10px;\&quot;><br>\n&quot;;
print &quot;<font face=verdana size=-2 color=black><b>password:</b></font>\n&quot;;
print &quot;<br><input type=\&quot;password\&quot; name=\&quot;password\&quot; style=\&quot;background:00648E; color:white; height:20; font-size:10px;\&quot;><br>\n&quot;;
print &quot;<input type=\&quot;submit\&quot; value=\&quot;Enter\&quot; style=\&quot;background:black; color:white; height:20; font-size:10px;\&quot;>\n&quot;;
print &quot;<input type=\&quot;Reset\&quot; value=\&quot;Clear\&quot; style=\&quot;background:black; color:white; height:20; font-size:10px;\&quot;>\n&quot;;
print &quot;</form>\n&quot;;
print &quot;</body>\n</html>\n&quot;;
}


sub checkpassword {
open(FILE, &quot;$datadir/data.txt&quot;) || die(&quot;File does not reside on server: $!&quot;);
while (<FILE>) {

@data = split(/\n/);
foreach $entry (@data) {
($user, $password) = split(/,/, $entry);
if ($FORM{'user'} eq &quot;$user&quot;) {
$userverified = &quot;1&quot;;
}
if ($FORM{'password'} eq &quot;$password&quot;) {
$passwordverified = &quot;1&quot;;
}
}
}
close(FILE);

if ($userverified &amp;&amp; $passwordverified) {
&amp;accessgranted;
} elsif ($userverified) {
&amp;badpassword;
} else {
&amp;baduserpass;
}
}

sub accessgranted {
print &quot;content-type: text/html\n\n&quot;;
print &quot;<html><head><title>access granted</title></head>\n&quot;;
print &quot;<body>\n&quot;;
print &quot;<h1>access granted</h1>\n&quot;;
print &quot;welcome to the by me, vic cherubini.\n&quot;;
print &quot;<br>select what you want to do.\n&quot;;
print &quot;</body>\n&quot;;
print &quot;</html>\n&quot;;

}

sub badpassword {
print &quot;content-type: text/html\n\n&quot;;
print &quot;<html><head><title>bad password</title></head>\n&quot;;
print &quot;<body>\n&quot;;
print &quot;<h1>bad password</h1>\n&quot;;
print &quot;</body>\n&quot;;
print &quot;</html>\n&quot;;

}

sub baduserpass {
print &quot;content-type: text/html\n\n&quot;;
print &quot;<html><head><title>bad username and password</title></head>\n&quot;;
print &quot;<body>\n&quot;;
print &quot;<h1>bad username and password</h1>\n&quot;;
print &quot;</body>\n&quot;;
print &quot;</html>\n&quot;;

}


[/tt]


If you need more help, don't hesitate to ask.

-Vic

vic cherubini
malice365@hotmail.com
====

Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

Wants to Know: Java, Cold Fusion, Tcl/TK

====
 
good effort vik, you should be commended. You were willing to invest more than I. Good try. I hope Oxymoron got what he/she needed.




keep the rudder amid ship and beware the odd typo
 
Hi again
wow, thanx vik.
All I wanted to know was if it was possible.
But thanx everyone for the help.
I've started to learn Pearl, and so understood some of Vik's code. I shan't use it till I can understand it, and appreciate it, and will give a link to any site he/she may own.
Thanx once again
JOE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top