PHP Developers Network

Need som help with logics - Editing lines in a flatfile
Page 1 of 1

Author:  PT [ Sat Apr 30, 2005 4:51 pm ]
Post subject:  Need som help with logics - Editing lines in a flatfile

Ok, what I have got is an array containing some e-mail addresses. One e-mail address is one line in my db-file. What I want is for the user to be able to select one or more of these e-mail addresses and edit them. The selected e-mail adresses are stored in a new array. How can I in the best way check if the e-mail address already exist (this is the real problem; I cannot find out if the e-mail address is really changed or not), and if it does not, create a new array containing all the e-mail addresses, both those that was not selected and those that were?
I am really stuck on this one. It will be used in a flatfile mailinglist system.

Author:  Calimero [ Sat Apr 30, 2005 6:08 pm ]
Post subject:  ...

Have you looked at the manual:

Load the file - I think it is fopen(), and then just do a simple checking with preg_match() or in_array(), or just with "==" comparison, to see if the record exists.

Other way is to load the file and in PHP constuct and array of these values.
Again just take new records and cross-reffernce them.

After that, just write to the file what ever you need.

Author:  PT [ Sat Apr 30, 2005 6:19 pm ]
Post subject:  Re: ...

Author:  Calimero [ Tue May 03, 2005 10:46 am ]
Post subject:  ...

I don't understand why do you do checking that way ?!?!

So your goal is just to check that user doesn't insert existing emails in the database, right ?

If so just check the data that was inputed - create an array of those selected, but check to see which (of the members of that array ) the user realy changed ( trough checking the input of the FORM from the page - give one textfield for each selected email, if the field is empty() use array_splice() or unset() on the coresponding member of an array - the array that contains the selected emails ).

This will leave only those mails that user has changed.

To be even more safe - if someone tries to bug your system - when the user submits the FORM check each member of an array with the corresponding textfield and see if they are the same, and if they are - kick that member of an array out.

Is this what you needed?

Author:  PT [ Tue May 03, 2005 11:18 am ]
Post subject:  Re: ...

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group