Current location: Hot Scripts Forums » Programming Languages » PHP » email duplicate check


email duplicate check

Reply
  #1 (permalink)  
Old 03-15-04, 07:12 PM
jrave jrave is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down email duplicate check

new script...new problems

im writing a mailing script for an application page on a website on the electrical interweb.

the following function is 'sposed to check if the email has been used before and if the applicant met cirtain requirements. 'sposed to.

PHP Code:

function checkemail($emailtocheck) {

    
$handle fopen("emailstore.db""r");
    
$contents fread($handlefilesize($filename));
    
fclose($handle);

    
$isfound "false";
    
$emails explode("<"$contents);
    
$count count($emails);
    for (
$i=0$i<$count$i++) {
        print 
"pre-explode check: max- $count this- $i as- $emails[$i]<br>\n"// debugging
        
list ($thisemail$thisaccepted) = explode(">"$emails[$i]);
        print 
"explode check: 0- $thisemail 1- $thisaccepted<br>\n"// debugging
        
if ($thisemail == $emailtocheck) {
            
$isfound="true";
            break;
        }
    }
    
    if(
$isfound=="true") {
        return array(
"true""$thisaccepted");
    } else {
        return array(
"false""$thisaccepted");
    }

how ever it is not returing much at all!

the database it reads is stored like this: foo@bar.com>no<bob@job.com>yes

can anyone help? the debugging lines dont return anything derived from the $email array

ta
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-16-04, 01:48 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,

What's in your $filename? I assume you wanted to get the file contents of the file emailstore.db into the var $contents. In that case, this variable ($filename) has to hold a value "emailstore.db".

Another tip I can give you is that, if you do not have to read the file in small chunks, you can use this:

PHP Code:

// Assumption is that $filename holds "emailstore.db"

$contents file_get_contents($filename); 
instead of

PHP Code:

// Assumption is that $filename holds "emailstore.db"

$handle fopen($filename"r");
$contents fread($handlefilesize($filename));
fclose($handle); 
file_get_contents() is faster and shorter.

Hope this helps.
__________________
Blavv =|
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-16-04, 09:04 PM
jrave jrave is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
thanks very much, i had copyed the file reading block over from anouther section of the code and had only replaced the onle line.
and i now use file_get_contents() everywhere i go

thanks

untill next time
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
delete duplicate rows in mysql using php seans9 PHP 4 07-16-08 10:42 PM
Validate email on Mysql and Redirect dihan PHP 4 01-18-04 07:35 AM
Bidflux Blackadder General HotScripts Site Discussion 10 11-08-03 01:49 PM
Form to database to email BogoMips ASP 0 11-03-03 07:12 AM
Preventing email form abuse LunarOrbit Perl 3 10-04-03 10:55 PM


All times are GMT -5. The time now is 12:19 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.