Email validation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Email validation (/showthread.php?tid=37569) |
Email validation - El Forum - 01-13-2011 [eluser]yorvik[/eluser] Hello, CI uses this for the form_validation of emails: Code: return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; But when I want to add this emailadres: [email protected], I always get an error of not valid email. How can I fix this. Thanks in advance Email validation - El Forum - 01-13-2011 [eluser]Cristian Gilè[/eluser] It works for me. Please, provide your code. Cristian Gilè Email validation - El Forum - 01-13-2011 [eluser]yorvik[/eluser] Code: <?php I think it has something to do with this: $email = mysql_real_escape_string($_POST['signup-email']); Email validation - El Forum - 01-14-2011 [eluser]Atharva[/eluser] First, run the regex and then use Code: mysql_real_escape_string() In fact, why you are not using CI's inbuilt class Code: if(!preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $email)){ Email validation - El Forum - 01-14-2011 [eluser]yorvik[/eluser] OK thank you no I am not inserting the post value. I was testing this when I realised I don't need to use mysql_real_escape_string. Thanks anyway:p |