| | |
Validating Email Addresses - A little extra help!
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2005
Posts: 13
Reputation:
Solved Threads: 0
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:
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

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)
function if_email($staff) { //Check the valididty of the email address entered if (ereg('^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $address)) return true; else return false; }
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
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
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)
function if_email($email) { //Check to make sure this is a valid email address on landau-forte.org.uk if (ereg('^[a-zA-Z0-9_\.\-]+@landau-forte.org.uk$', $email)) return true; else return false; }
•
•
•
•
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)
function if_email($email) { //Check to make sure this is a valid email address on landau-forte.org.uk if (ereg('^[a-zA-Z0-9_\.\-]+@landau-forte.org.uk$', $email)) return true; else return false; }
I.e.
PHP Syntax (Toggle Plain Text)
function if_email($email) { //Define check $bademail = '\[USERNAME\]'; //Check that [USERNAME] is not contained in e-mail field if (ereg($bademail . '@^[\w_\.\-]$', $address)) return false; else if (ereg('^[\w_\.\-]+@[\w\-]+\.[\w\-\.]+$', $address)) return true; else return false; }
that *should* work
![]() |
Similar Threads
- deleteing email addresses (Windows Software)
- Problem with spam and spoofed email addresses (Networking Hardware Configuration)
Other Threads in the PHP Forum
- Previous Thread: Problems with uising arrays and $_POST variables
- Next Thread: $variable inside quotes
Views: 4015 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class clean cms code countingeverycharactersfromastring cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail match menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions simple sms soap source space spam speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





