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:

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 ;)

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?

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

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;
}

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

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;
}

He wants a script to validate that an e-mail address HAS been entered.

I.e.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.