Archive for the 'Information' Category

Date Validation Tutorial

Thursday, June 10th, 2010

Date Validation in PHP

This tutorial will show how to Validate Date fields using PHP code in ‘dd/mm/yyyy’ Format. It is a good practice to validate the date value when it is obtained using forms through user input.

PHP CODE:

//Check whether the submission is made
if(!isset($_POST["hidSubmit"])){
//Declarate the necessary variables
$strdate="";
$strdate1="";
DisplayForm();
}
else{
$strdate=$_POST["txtdate"];
//Check the length of the entered Date value
if((strlen($strdate)<10)OR(strlen($strdate)>10)){
echo(“Enter the date in ‘dd/mm/yyyy’ format”);
}
else{
//The entered value is checked for proper Date format
if((substr_count($strdate,”/”))<>2){
echo(“Enter the date in ‘dd/mm/yyyy’ format”);
}
else{
$pos=strpos($strdate,”/”);
$date=substr($strdate,0,($pos));
$result=ereg(“^[0-9]+$”,$date,$trashed);
if(!($result)){echo “Enter a Valid Date”;}
else{
if(($date<=0)OR($date>31)){echo “Enter a Valid Date”;}
}
$month=substr($strdate,($pos+1),($pos));
if(($month<=0)OR($month>12)){echo “Enter a Valid Month”;}
else{
$result=ereg(“^[0-9]+$”,$month,$trashed);
if(!($result)){echo “Enter a Valid Month”;}
}
$year=substr($strdate,($pos+4),strlen($strdate));
$result=ereg(“^[0-9]+$”,$year,$trashed);
if(!($result)){echo “Enter a Valid year”;}
else{
if(($year<1900)OR($year>2200)){echo “Enter a year between 1900-2200″;}
}
}
}
DisplayForm();
}
//User-defined Function to display the form in case of Error
function DisplayForm(){
global $strdate;

Explanation
*Expression ^[0-9]+$
^ :-Indicates the beginning of the string
[0-9]+ :- indicates that the string begins with a number between (0-9) and is followed by numbers.
$ :- Indicates the end of the String

Basic PHP Syntax

Monday, May 10th, 2010

A PHP scripting block usually starts with . The best thing about PHP scripting block is that you can place it anywhere in the document. placed anywhere in the document.

On servers with shorthand support enabled you can start a scripting block with .

It is recommend that you use the standard form

< html >
< body >

< ? php
echo "Hello World";
? >

< /body >
< /html >< /em >

Every line in PHP ends with a semi-colon. The two basic output text in PHP are: Echo and Print.

Smarty – the right stuff?

Monday, June 22nd, 2009

Smarty is categorized as a “Template engine”, though developers describe it more detailed as a “Template/Presentation Framework”, that offers developers and programmers ample tools to make extensive coding tasks easier by replacing tags with their appropriate counterparts. Smarty is aimed to hasten and make the development process simpler for all who aim to develop pages for the internet. (more…)

Cross-Site Scripting Tips

Friday, May 22nd, 2009

There are several platforms on which web pages are deployed and with thousands of people using different versions of software, scripting languages should be endowed with the proper set of tools that determines the proper set of scripts. Scripts for one platform may differ in form in another so a conversion method should be deployed to allow them to properly interface with each other. Though done behind the scenes, it is of utmost importance making the web experience more enjoyable with an example of the script below for reference. (more…)

PHP – Wide Gaping Security Risk?

Wednesday, April 22nd, 2009

With many of the internet’s web pages and applications based on PHP, many questions are being raised by the security and robustness of the system so to speak as we go through years of rapid development. Now the scripting language that is PHP isn;t meant to be weak security-wise and the problem lies with the sloppy work programmer have done all through the years that have left quite large and gaping security holes in something we so rely on. One event that greatly tripped the panic meters of developers the world over is the departure of one of the world’s leading authority on PHP, Stephan Esser, one of the founders of the language and a foundation of the web with him stating as an explanation that the security issues that are currently coming out are happening without his knowledge. (more…)

Separating Roles

Sunday, March 22nd, 2009

In web development, it is quite necessary to separate the roles of the page designer and the programmer which handles more of the logical or program side of the whole page. Designing a page is the task of making it interesting and quite pleasing to the prospective users who want something that is easy on the eyes yet loaded with functions that performs their needs. The template designer handles the framework onto which the logic is presented visually which is the norm of the internet which relies on graphics and other nifty trinkets to make their users happy customers. (more…)

Don’t be an elitist!

Tuesday, February 10th, 2009

One of the most basic mistakes people make in PHP programming is failing to resize their images and files. Because it is supposedly a “small” thing, this is precisely what makes it easy for many PHP programmers to overlook.

Dont be an elitist!

Don't be an elitist!

What the failure to resize simply does is to make your site harder to access, as people with slower internet connections or short attention spans (or worse, both) will just skip viewing your site altogether, which would be a shame if your site and your content is well crafted. You might as well put a big bright disclaimer on your site that says, “People with slow internet connections – GO AWAY.” And that, friends, is elitism, albeit unintentionally done.

PHP- To Fix the Broken WEB

Monday, January 12th, 2009

internet3The internet is a collection of broken stuff that may be too large for anyone or any company to fix so what do you do? Fix it with the growing popular PHP language that has been used again an again and is responsible for most of the web applications we use over the internet today. Being used by most open-source developers it has provided most of the web’s most innovative applications with millions of pages and users. From blogs to sites and apps, they all have one thing in common, PHP. Too many experts claiming this and that, unorganized moves to improve and develop systems for the net has left it broken as hell and the best way to fix it? (more…)

PHP 2.5.8. Update

Saturday, December 13th, 2008

It’s that time of the month to check if there’s a new update for PHP and (gasp!) there is one!

Due to a security bug found in the PHP 5.2.7 release, it has been removed from distribution. The bug affects configurations where magic_quotes_gpc is enabled, because it remains off even when set to on. In the meantime, use PHP 5.2.6 until PHP 5.2.8 is later released.

The PHP Development Team would like to announce the immediate availability of PHP 5.2.8. This release addresses a regression introduced by 5.2.7 in regard to the magic_quotes functionality, which was broken by an incorrect fix to the filter extension. All users who have upgraded to 5.2.7 are encouraged to upgrade to this release. Alternatively you can apply a work-around for the bug by changing “filter.default_flags=0″ in php.ini.

Go ahead and update this one right away as it will save your IT hide.

Source

Tips for Php

Tuesday, November 25th, 2008

Image Source: filemaker.com

If you are new to programming, chances are you will be more likely intimidated by PHP. PHP is the newest scripting language that is gaining popularity across the globe. This is simply because it provides a very basic principle in programming. No complicated stuff that will get you lost along the way. In relation to this, your fear of PHP is due to the fact you might have a limited understanding on how it works. Because once you get to know the important details, you should have no problem programming your stuff in no time. The most important thing you should know before you come to like PHP is an extensive understanding of HTML. This is primarily because PHP and HTML wil supplement each other in your programming.