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!

Creating a Text-Based DB

Status
Not open for further replies.

mtorbin

Technical User
Nov 5, 2002
369
US
Hey all,

I'm starting a new script and I was wondering if I could get some help from you. Here's the idea:

1) People will submit their name and password via a form.
2) If the entry exists, then the person will be "signed in".
3) If the entry DOES NOT exist, then the person will have to
create a new entry.
4) At the end of the day, the person would "sign out".

It's pretty simple, but the hard part, in my mind, will be creating the text-based DB. This is where I could use some pionters to references or examples. Below is a sample of what a DB entry might look like:

[KEY] [USERNAME] [PASSWORD] [TIME IN] [TIME OUT]

I'll also want to pull this information out so that anyone can see if someone is "signed in".

Well, where do I begin? Where can I look for help with text-based DB's?

Thanks,

- MT

Matt Torbin
Web and Graphic Arts Engineer
PEI-Genesis

aim: dgtlby
direct email: mtorbin_at_earthlink.net
 
OK, so here's where I am so far. I have a small script that (although I must severely clean up later) will write to a file called logSheet.dat. It writes the following information:

[KEY]|[USERNAME]|[PASSWORD]|[TIME IN]|[TIME OUT]

So a sample log might look something like this:

0001|mtorbin|password|Tue May 18 13:53:05 2004|timeOUT (if there was one)

So now my question is, how do I go about splicing up the last entry in the log?

- MT

Matt Torbin
Web and Graphic Arts Engineer
PEI-Genesis

aim: dgtlby
direct email: mtorbin_at_earthlink.net
 
Here's the entire piece of code that I have. Now, if I want to call just the one subroutine, how do I set up the url?



#!/usr/bin/perl -wT
print "Content-type:text/html\n\n";

$ipAddress = $ENV{'REMOTE_HOST'};
$logTime = gmtime(time);

sub writeEntry {
# This is the important bit...
open(fileOUT, ">>logSheet.dat") or dienice("Can't open the log sheet for writing: $!");
flock(fileOUT, 2); seek(fileOUT, 0, 2);

print fileOUT "0001|mtorbin|password|$logTime|timeOUT\n";
close(fileOUT);

# If all went well, output thank you message
print <<EndHTML;
<html><head><title>Thank You</title></head>
<body>
<h2>Thank You!</h2><br>
Thank you. Your entry has been added to our database.
</body></html>
EndHTML
}

# Error Trapping Sub...should things go pear shaped!
sub dienice
{
my($msg) = @_;
print "<html>\n<head>\n<title>Error Opening File!</title>\n";
print "</head>\n";
print "<body><h2>Error</h2>\n<b>";
print $msg;
print "\n</b></body>\n</html>";
exit;
}

Would it be:

http://[myDOMAIN].com/cgi-bin/myDB.cgi?writeEntry

- MT

Matt Torbin
Web and Graphic Arts Engineer
PEI-Genesis

aim: dgtlby
direct email: mtorbin_at_earthlink.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top