Anyway... my problem --
1) I have a flatfile database, in the form of:
$usernum ¦ $rights ¦ $active ¦ $email ¦ $firstname ¦ $lastname ¦ $password ¦$username
So the exact layout with dummy examples would look something like:
<modnote>broke the following lines for sidescroll fix</modnote>
usernum=1¦rights=administrator¦active=yes¦email=sarah@site1.com
¦firstname=Sarah¦lastname=Anne¦password=hello¦username=SarahAnne
usernum=2¦rights=guest¦active=yes¦email=jamesd@site2.com¦
firstname=james¦lastname=duffield¦password=hello¦username=jamesd
And so forth.
2) I would like to be able to read this data so that a user would go to my script (master.cgi) with an indication of a certain user and the information for that user was displayed, kind of a profile. I.e. if a user were to click master.cgi?action=ViewProfile&pro=jamesd
then the information on user "jamesd" would be displayed, i.e. $firstname and $lastname and so on. The ViewProfile is a subroutine and pro= is just telling the script which profile needs to be displayed.
I've tried several things to sort this (what seems to be a pretty simple) problem but no luck. I'm not particularly good with Perl, but here are some of my solutions, none of which work as they are....
(BTW, a big thank you to anyone who can help me with this! :) )
Sarah.
P.S. Sorry for messing up this lovely board with all this code... I just know this is going to get those horrid horizontal bars showing :(
=========================================================
open(FILE, "users.dat");
@indata = <FILE>;
close(FILE);
open(FILE, "users.dat");
foreach $temp (@indata)
{
($usernum, $rights, $active, $email, $firstname, $lastname, $password, $username) = split(/\¦/, $temp);
if ($username eq $pro) {
print FILE "$usernum, $rights, $active, $email, $firstname, $lastname, $username ";
}
else { print FILE "No one by that name!"; }
}
close(FILE);
====================================================
$database='users.dat';
if (&ReadParse())
{
open (DATABASE,$database);
@database_in=<DATABASE>;
foreach $_ (@database_in)
{
($usernum, $rights, $active, $email, $firstname, $lastname, $password, $username)=split(/\¦/);
$temp="$pro";
if ($temp =~ /$in{'searchkeys'}/i)
{
$output=$output." $usernum <br> $username who is $firstname $lastname";
}
}
print "Search Results\n";
print "<b>Search for <i>$in{'searchkeys'}</i> returned:</b><P>\n\n";
if ($output eq "")
{
print "I am sorry, but right now <b>$in{'searchkeys'}</b> is not available. $database='users.dat';
if (&ReadParse())
{
print &PrintHeader;
open (DATABASE,$database);
@database_in=<DATABASE>;
foreach $_ (@database_in)
{
($usernum, $rights, $active, $email, $firstname, $lastname, $password, $username)=split(/\¦/);
$temp="$pro";
if ($temp =~ /$in{'searchkeys'}/i)
{
$output=$output." $usernum <br> $username who is $firstname $lastname";
}
}
print "Search Results $output ";
print "<b>Search for <i>$in{'searchkeys'}</i> returned:</b><P>\n\n";
if ($output eq "")
{
print "I am sorry, but right now <b>$in{'searchkeys'}</b> is not available.\n";
}
else
{
print " ";
print " ";
}
print " ";
}
else
{
print " ";
}\n";
}
else
{
print " ";
print " ";
}
print " ";
}
else
{
print " ";
}
==================================================================
open(file,"data.dat");
@lines=<FP>;
close (FP);
chomp @lines;
foreach $i (@lines)
{
($prod_code, $name, $colour, $size, $price)=split(/\¦/);
$name{$prod_code}=$name;
$colour{$prod_code}=$colour;
$size{$prod_code}=$size;
$price{$prod_code}=$price;
}
$code="100";
print "Product $code is a $name{$code} in colour $colour{$code}, of size $size{$code} costing $price{$code}<Br>";
===================================================================
[edited by: jatar_k at 10:39 pm (utc) on May 21, 2003]
[edit reason] fixed sidescroll and removed specifics [/edit]