Jump to content

Simple Regex email check


jamiet757

Recommended Posts

I have a script that checks to see if an email address is already in the database before a user can register, for some reason it isn't working right, but I don't know why. Here is what I have so far:

 

<?php
include("../admin/function/db.php");
include("JsHttpRequest.php");

$JsHttpRequest =& new JsHttpRequest($mtg);

$email=result3($_REQUEST['email']);

if($_REQUEST['email']=="" or !preg_match("/[\.\-_A-Za-z0-9]+?@[\.\-A-Za-z0-9]+?[\.A-Za-z0-9]{2,}/",$_REQUEST['email']))
{
echo("<span class='error'>".word_lang("incorrect")."</span>");
}
else
{
$sql="select email from users where email='".$email."'";
$rs->open($sql);
if(!$rs->eof)
{
echo("<span class='error'>".word_lang("serror2")."</span>");
}
else
{
echo("<span class='ok'>".word_lang("ok2")."</span>");
}
}
?>

I think the problem lies in the preg_match section, but I haven't a clue how it should be formatted.

Link to comment
https://forums.phpfreaks.com/topic/190182-simple-regex-email-check/
Share on other sites

I replaced the original with this:

if($_REQUEST['email']=="" or filter_input(INPUT_REQUEST, 'email', FILTER_VALIDATE_EMAIL) != $_REQUEST['email'])

 

But I get this error now:

Warning:  filter_input() [function.filter-input]: INPUT_REQUEST is not yet implemented in check_email.php on line 9

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.