/    Sign up×
Community /Pin to ProfileBookmark

Personal details (editable) from flatfile…

Resolved.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@bokehAug 15.2005 — If you must use a flatfile database I think it would be best to write a separate file for each user. The reason is if your users.txt were ever to be corrupted you would be in big trouble and the second reason is the individual file would be much more manageable. You could put all the data in one row and delimit it with commas or some other punctuation.

So to sum up the file could be named 'username.txt' and contain:

coded_password,First name,Middle name,Surname,House number/Name,Road name,Town,County,Country,Telephone_Number,Mobile,Fax numbers,e-mail

All you would need to do is:
[code=php]$keys = array(
'coded_password',
'First name',
'Middle name',
'Surname',
'House number/Name',
'Road name',
'Town,County',
'Country',
'Telephone_Number',
'Mobile','Fax numbers',
'e-mail'
);
$user = file_get_contents($username.'.txt');
$user = explode(',' $details);

$i = 0;
foreach($user as $value){
$key = $keys[$i];
$details[$key] = $value;
$i++;
}[/code]


now to access the user telephone number just use [code=php]$user['Telephone_Number'][/code]

Just ideas.
Copy linkTweet thisAlerts:
@DanUKauthorAug 15.2005 — Hi bokeh; thanks for your reply - that looks good!

The PHP bit, would that get put into the details.php that will come up with the details for the individual?

For the actual .txt file would it be layed out like:

First name,Middle name,Surname,House number/Name,Road name,Town,County,Country,Telephone_Number,Mobile,Fax numbers,e-mail

all on the same line just seperated with commas?

Also..what is coded_password for? The password stuff is all dealt with elsewhere.

Then on details.php... I could just create a table and in the applicable TD's just put:

[code=php]<?php echo $user['Telephone_Number']; ?>[/code]

To actually edit the details though, would that be hard based on teh script provided?

Thanks for the support; I really appreciate it!!!
Copy linkTweet thisAlerts:
@bokehAug 15.2005 — Each user's info would be in their user file not elsewhere so password would be the first field. As stated earlier keeping this info in one single file is dangerous for the point of view of being corrupted.

As for the user file you could either lay it out on one line and delimit with, for example, commas or you could put each item on a new line.

I could just create a table and in the applicable TD's just put:[/QUOTE]
yes.

Editing the details would be easy (but not as easy as with mysql) just open the text file read the details, edit as required and then overwrite the file.

Lastly all that code I posted was a way to access a user file but nothing more.
×

Success!

Help @DanUK spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...