/    Sign up×
Community /Pin to ProfileBookmark

help web form that reads from a text file

hi guys for my text file called “letter.txt” it contains
Michael, BMW, 20
Arg, SUSUKI 19,
Sean, HONDA, 18,
Elda, BMW, 30

HERE 20 IS FOR AGE.

what i want to do is have a webform that allows users to enter the age and then if the age is less than 20 when the user click on submit then the list of all the names and age of people below 20 should be displAYED. any idea how to do that. pls.

thanks.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@SpectreReturnsOct 29.2005 — First of all, standardize your file, you can't have some lines ending with a comma and not others.

Second, have the form be submitted, then check what the given age is.
[code=php]
$temp = file('lolwhatever');
$data = array();
foreach ($temp as $key=>$val) {
$data[$key] = explode(", ", $val);
}
[/code]

$data is now an 2d array of [user][data]. Now you will need to go through each one and check their age upon the given age.
×

Success!

Help @chickenyd 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.17,
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,
)...