Validating Email Addresses - A little extra help!

Reply

Join Date: Jan 2005
Posts: 13
Reputation: nikez is an unknown quantity at this point 
Solved Threads: 0
nikez nikez is offline Offline
Newbie Poster

Validating Email Addresses - A little extra help!

 
0
  #1
Jan 10th, 2005
Hi guys....newbie on the forums here

I have developed a php form processor for a project i am working on. I am trying to validate the email address, however i want to add 1 more check the the default script. At the moment i have the following:

  1. function if_email($staff)
  2. {
  3. //Check the valididty of the email address entered
  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. }

Which I have taken from a PHP book i am working with. My question is as follows:

The textbox that the $staff variable is linked to has the text "[USERNAME]@landau-forte.org.uk" pre-defined in it. Staff must change the username section for their own. Can someone tell me how to check...if the email has the phrase '[USERNAME]' in it then return it as an error?

Thanks for your help,

JameZ
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 72
Reputation: HawkeVIPER is an unknown quantity at this point 
Solved Threads: 4
HawkeVIPER's Avatar
HawkeVIPER HawkeVIPER is offline Offline
Junior Poster in Training

Re: Validating Email Addresses - A little extra help!

 
0
  #2
Jan 14th, 2005
why not drop everything after the @, add that on using php after they click submit or whatever, then just verify the [USERNAME] box with a if $x = statement?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: Validating Email Addresses - A little extra help!

 
0
  #3
Jan 14th, 2005
ok I think this was what u asked. ..
you wanted a script that validating some e-mail address that *MUST* have a domain of landau-forte.org.uk
if i am correct then this should do the job

  1. function if_email($email)
  2. {
  3. //Check to make sure this is a valid email address on landau-forte.org.uk
  4. if (ereg('^[a-zA-Z0-9_\.\-]+@landau-forte.org.uk$', $email))
  5. return true;
  6. else
  7. return false;
  8. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 72
Reputation: HawkeVIPER is an unknown quantity at this point 
Solved Threads: 4
HawkeVIPER's Avatar
HawkeVIPER HawkeVIPER is offline Offline
Junior Poster in Training

Re: Validating Email Addresses - A little extra help!

 
0
  #4
Jan 14th, 2005
Originally Posted by paradox814
ok I think this was what u asked. ..
you wanted a script that validating some e-mail address that *MUST* have a domain of landau-forte.org.uk
if i am correct then this should do the job

  1. function if_email($email)
  2. {
  3. //Check to make sure this is a valid email address on landau-forte.org.uk
  4. if (ereg('^[a-zA-Z0-9_\.\-]+@landau-forte.org.uk$', $email))
  5. return true;
  6. else
  7. return false;
  8. }
He wants a script to validate that an e-mail address HAS been entered.

I.e.

  1. function if_email($email) {
  2.  
  3. //Define check
  4. $bademail = '\[USERNAME\]';
  5. //Check that [USERNAME] is not contained in e-mail field
  6. if (ereg($bademail . '@^[\w_\.\-]$', $address))
  7. return false;
  8. else if (ereg('^[\w_\.\-]+@[\w\-]+\.[\w\-\.]+$', $address))
  9. return true;
  10. else
  11. return false;
  12. }

that *should* work
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 13
Reputation: nikez is an unknown quantity at this point 
Solved Threads: 0
nikez nikez is offline Offline
Newbie Poster

Re: Validating Email Addresses - A little extra help!

 
0
  #5
Jan 17th, 2005
Thanks everyone for your suggestions.

Will have a mess about with what you all posted and see if i can make it work

Cheers,
JameZ
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 4015 | Replies: 4
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC