[Phpwm] Simple PHP Contact Form

phil at infolinkelectronics.co.uk phil at infolinkelectronics.co.uk
Tue Oct 13 22:09:08 UTC 2009


> You'd be best off performing some sort of regular expression match -
> or using the filter extension ...
>
> $email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
> if(!$email) {
>         // invalid email address
> }
> (Requires PHP5, I think my syntax/usage is correct, but I've not
> checked it)

The regex is (acting on the incoming variable $emaila)

if (!eregi ("^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$",
$emaila)) error_alert("Invalid Email Address");

where:-

function error_alert($msg){global $flag; $flag = 1; echo
"<script>alert(\"Error: $msg\");history.go(-1)</script>";}

Thats from a page where the form, validation and sending are done as three
invocations via a switch, case, do something and break method. a -1 history
kickback works.
The eregi bit should be fairly PHP version unspecific though.

Regards,

Phil Beynon
Sales & Operations Director

** Infolink Electronic Systems Ltd.
** S/W Birmingham's Longest Established ISV & VAR
** http://www.infolinkelectronics.co.uk
** Professional Web 2.0 Design & Advanced Hosting Platforms
** http://www.coeus-computica.co.uk
** Affordable Knowledgebase Solutions
** Contact: Sales at infolinkelectronics.co.uk
** Tel / Fax 0121 441 3558
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Phil Beynon.vcf
Type: text/x-vcard
Size: 636 bytes
Desc: not available
Url : http://mailman.lug.org.uk/pipermail/phpwm/attachments/20091013/ba2ca809/attachment.vcf 


More information about the Phpwm mailing list