Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have the current code, but have just found out that is doesn't allow certain email addresses to work:
elseif (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from))
So if I have an email of:
mynamehere-@domain.comIt would fail, can anyone advise which part of the code I should change.
Thanks Ian

Hi, are you trying to validate the email address? I prefer using eregi function.
Perhaps try using preg_match with this regular expression:
/^[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+)+$/i
or
/^[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+)*@[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+)*$/

I've worked it out, by deleting part of the code:
elseif (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from))
By deleting the part in BOLD

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |