Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 27th, 2003, 11:22 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Valid Email Function

I have a function that I call to check if the email address is correct and return back an error.

the call

php Code:
Original - php Code
  1.  
  2. $vs = valid_email($email);
  3. if ($vs = false)
  4.     {
  5.     include '../inc/header.inc';
  6.     print "<td></td><td><br><br><center><font color=green><b>Opps is this correct email ?<$email> try again please.<br><br></center></font></b>n";
  7.     include '../inc/footer.inc';
  8.     die;
  9.     }


the function

php Code:
Original - php Code
  1.  
  2. function valid_email($email)
  3. {
  4.   // check an email address is possibly valid
  5.   if (ereg("^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$", $email))
  6.     return true;
  7.   else
  8.     return false;
  9. }


I can type type anything into the field and it will accept
any suggestions.....

Reply With Quote
  #2  
Old September 27th, 2003, 11:49 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Valid Email Function

This code will do the job.
php Code:
Original - php Code
  1. <?
  2. function valid_email($address)
  3. {
  4.     if(ereg('^[a-zA-Z0-9_]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$',$address))
  5.         return true;
  6.     else
  7.         return false;
  8. }
  9.  
  10. $result=valid_email('myname@mydomain.com');
  11. if($result)
  12.     echo "Email address is valid.";
  13. else
  14.     echo "Email address is invalid.";
  15. ?>

Reply With Quote
  #3  
Old September 27th, 2003, 11:51 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Valid Email Function

It seems like nothing wrong with your function to validate the email. The problem is on your calling part.

Be careful when you compare with the if condition.

the link in your code
php Code:
Original - php Code
  1.  
  2. if ($vs = false)


should be,
php Code:
Original - php Code
  1.  
  2. if ($vs == false)


Reply With Quote
  #4  
Old September 28th, 2003, 03:34 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Valid Email Function

or even better, do it the right way:

php Code:
Original - php Code
  1. if (!$vs) {
  2.     // ...
  3. }

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Valid Email Function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT