ali_2kool2002 Posted April 21, 2007 Share Posted April 21, 2007 Hi can someone explain how the code works so at least i know how php does it instead of just using it from here the first code checks if there are no numbers in the text field for name but what do those characters in preg match mean same applies for how does the email validation work? Thanks for anyone to crack this cheers : if ( !preg_match('/^[a-zA-Z\" "]*$/', $yname) ) { error('Name is not Valid.\\n'. 'Please try again.'); }Repeat it for every text box u want to validate. Use this for email validation: Code: if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $yemail)){ error("Invalid e-mail address"); } Link to comment https://forums.phpfreaks.com/topic/48015-solved-code-explanation-please/ Share on other sites More sharing options...
keeB Posted April 21, 2007 Share Posted April 21, 2007 Those are called Regular Expressions (regex for short.) They're a pain in the butt to learn! Link to comment https://forums.phpfreaks.com/topic/48015-solved-code-explanation-please/#findComment-234690 Share on other sites More sharing options...
taith Posted April 21, 2007 Share Posted April 21, 2007 [_a-z0-9-] --> any letters, a-z, or numbers 0-9 (\.[_a-z0-9-]+) --> followed by a maybe a "." , and any letters/numbers @[a-z0-9-] --> an @ symbol, followed by any letters/numbers (\.[a-z0-9-]+) --> followed by maybe a ".", and any letters/numbers (\.[a-z]{2,4}) --> followed by a dot, and any letters/numbers, thats between 2-4 characters long if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $yemail)){ error("Invalid e-mail address"); } if that helps any... Link to comment https://forums.phpfreaks.com/topic/48015-solved-code-explanation-please/#findComment-234694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.