jamiet757 Posted January 29, 2010 Share Posted January 29, 2010 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. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted January 29, 2010 Share Posted January 29, 2010 filter_input can be used with the FILTER_VALIDATE_EMAIL flag to check for validity of email formats. in your case it would be filter_input(INPUT_REQUEST, 'email', FILTER_VALIDATE_EMAIL) != $_REQUEST['email'] Quote Link to comment Share on other sites More sharing options...
jamiet757 Posted January 29, 2010 Author Share Posted January 29, 2010 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 Quote Link to comment Share on other sites More sharing options...
Andy-H Posted January 29, 2010 Share Posted January 29, 2010 Ahh, sorry about that, just read the manual on it. filter_var($_REQUEST['email'], FILTER_VALIDATE_EMAIL) === false Try that instead. Quote Link to comment Share on other sites More sharing options...
jamiet757 Posted January 29, 2010 Author Share Posted January 29, 2010 Great thanks, that worked like a charm! Quote Link to comment Share on other sites More sharing options...
Andy-H Posted January 29, 2010 Share Posted January 29, 2010 No problem mate Glad I could help, could you set the topic as solved please. (The solved button is at the bottom left in a green box, just in case you didn't know ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.