943,985 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 4235
  • PHP RSS
Jan 10th, 2005
0

Validating Email Addresses - A little extra help!

Expand Post »
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:

PHP Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nikez is offline Offline
13 posts
since Jan 2005
Jan 14th, 2005
0

Re: Validating Email Addresses - A little extra help!

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?
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
HawkeVIPER is offline Offline
72 posts
since Jan 2005
Jan 14th, 2005
0

Re: Validating Email Addresses - A little extra help!

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

PHP Syntax (Toggle Plain Text)
  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. }
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Jan 14th, 2005
0

Re: Validating Email Addresses - A little extra help!

Quote 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

PHP Syntax (Toggle Plain Text)
  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.

PHP Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
HawkeVIPER is offline Offline
72 posts
since Jan 2005
Jan 17th, 2005
0

Re: Validating Email Addresses - A little extra help!

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nikez is offline Offline
13 posts
since Jan 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Problems with uising arrays and $_POST variables
Next Thread in PHP Forum Timeline: $variable inside quotes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC