Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 28th, 2001, 08:50 PM
thenewuser thenewuser is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 13 thenewuser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
displaying info in text file after user login ?

hello all,

i was wondering if anyone can show me how to display the specific info in a text file after a user login ?

the text file keeps the data of all users of my website

the text file contains :-

username|password|email|address|phone



ps : i need a working example.

Thanks

Reply With Quote
  #2  
Old July 29th, 2001, 02:30 AM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,535 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 10
Send a message via Yahoo to jdk
Thumbs up what u exactly want ??

do u want do display info pertaining to the user who has logged in ??

or what ??

btw newuser, i think asking directly for example is not a good idea, i can give u the code but that way u will never learn.

so rather try to do things urself, if u face problem we are ready to help .

but not trying at all and asking solution from someone else is not a good idea.

and if u still want code, reply back i post it in next reply,

but that wouldnt be cool u know,

best of luck,
jd
__________________
_____________________________
d.k.jariwala (JD)
~ simple thought, simple act ~
I blog @ http://jdk.phpkid.org

Reply With Quote
  #3  
Old July 29th, 2001, 12:10 PM
thenewuser thenewuser is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 13 thenewuser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
please help with examples...

please help with examples...

i have been trying long to learn from book, etc.

but please help.

i am sure i can learn a little with examples with description of the code.


THANKS

Reply With Quote
  #4  
Old July 29th, 2001, 12:18 PM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,535 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 10
Send a message via Yahoo to jdk
Cool ok..

this is a perl code which is used to manipulate flat file database where record are | separated..

i use this for flat file manipulation.

can u get some idea from this ??

see as u r willing to learn i am just putting up the code, there are lots of comments i think u should be able to grasp it,

best of luck,
jd

Code:

#$database_file = "C:\\Program Files\\AbriaSoft\\Abria SQL\\Apache\\cgi-bin\\homepage\\database.db";
################################################################################
#
# Subroutine Used To Edit A Record In The Datafile
#

sub EditRecord
{
	# Check To See If We Have A Database File To Work With
	&CheckDataFile($database_file);

	# Get The Record Key And Field Values
	my ($key, @values) = @_;
	
	# Create A Temporary Filename
	my $tempfile_path = $database_file.".TMP";
	
	# Initialize The Record Found Variable
	my $found = 0;

	# Setup The Record String With The Key As The Primary Value
	my $record_string = $key;
	
	# Add Each Of The Values To The Record String
	foreach $value (@values) { $record_string .= "|$value"; }
	
	# And Finish It Off With An End Of Line Character
	$record_string .= "\n";

	# Open The Current Database File And The Temporary One
	open(OLD_DATA, "<$database_file") or die "Error";
	open(NEW_DATA, ">$tempfile_path") or die "Error";

	# Process Each Line Of The Current Database
	while(<OLD_DATA>)
	{
		# Get The Key Of The Current Record
		my ($temp_key, @temp_values) = split(/\|/, $_);
		
		# If It Is The One We Want To Edit Then Write Out The
		# New Record Otherwise Write Out The Current One
		if($key == $temp_key) { print NEW_DATA $record_string; $found = 1; }
		else { print NEW_DATA $_; }
	}
	
	# If We Didn't Find The Record Then Add It In
	if(!$found) { print NEW_DATA $record_string; }
	
	# Close The Files
	close(OLD_DATA);
	close(NEW_DATA);

	# And Copy The Temporary One Over The Top Of The Old One
	rename($tempfile_path, $database_file);
}

#
################################################################################
#
# Subroutine Used To Delete A Record In The Datafile
#
sub DeleteRecord
{
	# Check To See If We Have A Database File To Work With
	&CheckDataFile($database_file);

	# Get The Record Key And Field Values
	my ($key, @values) = @_;

	# Create A Temporary Filename
	my $tempfile_path = $database_file.".TMP";

	# Open The Current Database File And The Temporary One
	open(OLD_DATA, "<$database_file") or die "Error";
	open(NEW_DATA, ">$tempfile_path") or die "Error";
	

	# Process Each Line Of The Current Database
	while(<OLD_DATA>)
	{
		# Get The Key Of The Current Record
		my ($temp_key, @temp_values) = split(/\|/, $_);

		# If It Is Not The One We Want To Delete Then Write It Out
		if($key != $temp_key) 
		{ 
			print NEW_DATA $_; 
		}
	}

	# Close The Files
	close(OLD_DATA);
	close(NEW_DATA);

	# And Copy The Temporary One Over The Top Of The Old One
	rename($tempfile_path, $database_file);
}
#
################################################################################
#
# Subroutine Used To Read A Record In The Datafile
#
sub ReadRecord
{
	# Check To See If We Have A Database File To Work With
	&CheckDataFile($database_file);

	# Get The Record Key To Read
	my ($key) = @_;
	
	# Initialize The Record String Variable
	my $record_string = "";
	
	# Open The Current Database File
	open(DATA, "<$database_file") or die "Error";


	# Process Each Line Of The Current Database
	while(<DATA>)
	{
		# Get Rid of Any Newline Characters

		chomp($_);


		# Get The Key Of The Current Record
		my ($temp_key, @temp_values) = split(/\|/, $_);
				
		# If It Is The One We Want Then Store The Record String And Leave
		if($key == $temp_key)
		{
			$record_string = join("\|", $temp_key,@temp_values);
			last;
		}
	}

	# Close The File
	close(DATA);
	
	# Return The Record String
	return $record_string;
}



################################################################################


################################################################################
#
# Subroutine Used To Check If A Datafile Exists And Create It If Necessary
#
sub CheckDataFile
{
	# Get The Data File Name

	chdir($scriptroot) or HandleError("Can not change to #scriptroot.",$!,"Make sure $scriptroot exits !!");
	my ($data_file) = @_;

	# Check To See If The File Exists
	if(! -e $data_file)
	{
		# And If Not Then Create It
		open(TEMP, ">$data_file") or HandleError("Can not open $data_file for writing.",$!,"Make sure enough permissions are there to create one.");;
		close(TEMP);
	}
}
#
#################################################################################
#################################################################################

# Stop The 'require' Complaining
1;

Reply With Quote
  #5  
Old July 29th, 2001, 01:23 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
hmm. No file locking? I wouldn't use that code on anything you care about. As soon as you got concurrent users, you're at a major risk if data corruption / destruction.

You didn't write that, did you jdk?

Reply With Quote
  #6  
Old July 29th, 2001, 01:29 PM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,535 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 10
Send a message via Yahoo to jdk
Lightbulb u r right.

hi hero,

yeah no file locking..

btw i found this code from net and it is working for me satisfactorily...

actually my application is such that it allows only one user to access it at a time,

so i never needed it.

btw i think i never considered this too,

thx for pointing out,
jd

Reply With Quote
  #7  
Old August 4th, 2001, 05:11 AM
thenewuser thenewuser is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Posts: 13 thenewuser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks.

thanks.

haven't tried it yet.

what about file locking.

if my users are the surfers, i guess i need file locking.

is it hard to implement file locking.

would appreciate with example code.

THANKS AGAIN !

Reply With Quote
  #8  
Old August 4th, 2001, 05:21 AM
jdk's Avatar
jdk jdk is offline
phpkid ~~~~~~ :o)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,535 jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level)jdk User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 11 m 11 sec
Reputation Power: 10
Send a message via Yahoo to jdk
Lightbulb

flock function is same as unix system command flock.
i think u would like to read man page for flock. its detailed and it should get u goin.

in perl flock function is same as wat u can find flock on unix.

hope it helps,
jd

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > displaying info in text file after user login ?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway