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

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.
There are several platforms on which web pages are deployed and with thousands of people using different versions of software,
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
In web development, it is quite necessary to separate the roles of the page designer and the 
The 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 
