Archive

Posts Tagged ‘validate’

Validating an email address in PHP

May 13th, 2008

A small tutorial and example script to validate the format of an e-mail address. This is very useful when capturing e-mail addresses from visitors.
If you’re using the e-mail address to send out important information then it’s advisable to ask the user to enter it twice, to account for misspelling.
<?php

#email address to validate
$email = “name@domain.com”;

#validate format
if(!eregi(”^[_&a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+
(.[a-z0-9-]+)*(.[a-z]{2,4})$”, [...]

PHP/MySQL Programming , ,