PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Oct 15, 2019 6:26 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sat Apr 30, 2005 4:51 pm 
Offline
Forum Newbie

Joined: Sat Apr 30, 2005 4:43 pm
Posts: 4
Location: Bergen, Norway
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.


Top
 Profile  
 
 Post subject: ...
PostPosted: Sat Apr 30, 2005 6:08 pm 
Offline
Forum Contributor
User avatar

Joined: Thu Jan 22, 2004 7:54 pm
Posts: 310
Location: Milky Way
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.


Top
 Profile  
 
 Post subject: Re: ...
PostPosted: Sat Apr 30, 2005 6:19 pm 
Offline
Forum Newbie

Joined: Sat Apr 30, 2005 4:43 pm
Posts: 4
Location: Bergen, Norway


Top
 Profile  
 
 Post subject: ...
PostPosted: Tue May 03, 2005 10:46 am 
Offline
Forum Contributor
User avatar

Joined: Thu Jan 22, 2004 7:54 pm
Posts: 310
Location: Milky Way
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?


Top
 Profile  
 
 Post subject: Re: ...
PostPosted: Tue May 03, 2005 11:18 am 
Offline
Forum Newbie

Joined: Sat Apr 30, 2005 4:43 pm
Posts: 4
Location: Bergen, Norway


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group