Archive for the ‘PHP’ Category

I’ve always used JavaScript to validate e-mail addresses. However, it’s best not to rely solely on JavaScript for such things due to accessibility issues. For this reason I’ve begun using PHP for e-mail validation. While I’m quite adept at creating functions for various other (simpler) aspects of form validation, verifying the validity of an e-mail address submitted by a user is a little too much for my pea size brain to cope with. Having scoured the web quite comprehensively, the following is by far the most effective solution I’ve found so far:

http://www.linuxjournal.com/article/9585

It’s not exactly a one-line solution but it certainly does the trick better than anything else I’ve found. It’s also pretty easy to understand and, if you so wish, edit. I hope you find it useful!

Add This! Blinkbits Blinklist Blogmarks BlogMemes BlueDot BlogLines co.mments Connotea del.icio.us de.lirio.us Digg Diigo DZone Facebook FeedMeLinks Folkd.com Fleck Furl Google Google Reader icio.de IndianPad Leonaut LinkaGoGo Linkarena Linkter Magnolia Mister Wong MyShare Ask.com MyStuff Ask.com Yahoo! MyWeb Netscape Netvouz Newsgator Newsvine Oneview.de RawSugar reddit Rojo Segnalo Shadows Simpy SlashDot Smarking Sphere Spurl Startaid StumbleUpon TailRank Technorati ThisNext yigg.de Webnews.de ReadMe.ru Dobavi.com Dao.bg Lubimi.com Ping.bg Pipe.bg Svejo.net Web-bg.com Plugin by Dichev.com
6 Aug 2009

PHP e-mail validation

Author: Adam | Filed under: PHP, Web Design

A little tip for my fellow web designers. Some of you will already know how to do this, as it’s not overly complicated. However, some of you will not - for those people I hope this will be useful.

At the footer of most websites, you will have a copyright notice, along the lines of:

© Copyright 2009 TheMasterBrewer

Have you ever found it a nuisance having to update the year every January on all of your websites? I used to. But it’s actually very simple to make your websites automatically update themselves using a little nugget of PHP. Your web pages will of course have to be written in PHP if you use this method - basic HTML files (.htm or .html) or files coded in other languages (e.g. ASP, JSP, etc) won’t work.

So, what’s the code? You simply use the PHP date function to retrieve the current year. You can retrieve it in various formats, but the format we require is a four digit full numeric representation of the year. This is called using an uppercase ‘Y’. So, the code is simply:

date(’Y')

Simple, huh? You just echo this and it comes out as 2009, or whatever year it is. So, for the above copyright statement, your code would be:

&copy; Copyright <?php echo date('Y'); ?> TheMasterBrewer

That’s it. The next time the clock strikes midnight on New Year’s Eve, all your websites will automatically update the year in their copyright notices.

Many of you will read this and think “duh”, but hopefully some of you will find it useful. If you have any questions, let me know. Cya!

Add This! Blinkbits Blinklist Blogmarks BlogMemes BlueDot BlogLines co.mments Connotea del.icio.us de.lirio.us Digg Diigo DZone Facebook FeedMeLinks Folkd.com Fleck Furl Google Google Reader icio.de IndianPad Leonaut LinkaGoGo Linkarena Linkter Magnolia Mister Wong MyShare Ask.com MyStuff Ask.com Yahoo! MyWeb Netscape Netvouz Newsgator Newsvine Oneview.de RawSugar reddit Rojo Segnalo Shadows Simpy SlashDot Smarking Sphere Spurl Startaid StumbleUpon TailRank Technorati ThisNext yigg.de Webnews.de ReadMe.ru Dobavi.com Dao.bg Lubimi.com Ping.bg Pipe.bg Svejo.net Web-bg.com Plugin by Dichev.com