Thursday, 31 July 2014

Checking if Cookies are Enabled in Browser

The simplest way to check for cookies is via JavaScript. The following function will return a boolean value -> true if cookies are enabled:, otherwise will return false.
<script >
function are_cookies_enabled()
 var cookieEnabled = (navigator.cookieEnabled) ? true : false;

 if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled)
  cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
 return (cookieEnabled);

 var result= are_cookies_enabled();

A snippet of code using the function above was executed when you loaded this page. resutl will display true or false

Monday, 28 July 2014

Delete image from folder in php

We are using image upload coding image moved on particular folder. after delete that database record data only deleted but image stay on same folder,Following line of code is used to Delet image from folder.

Thursday, 24 July 2014

Get all dates between two dates using php code.

In this Example giving two dates as "2014-07-24" and "2014-07-31" it return all days between these two dates.
function getAllDatesBetweenTwoDates($strDateFrom,$strDateTo)

    $iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2),     substr($strDateFrom,8,2),substr($strDateFrom,0,4));
    $iDateTo=mktime(1,0,0,substr($strDateTo,5,2),     substr($strDateTo,8,2),substr($strDateTo,0,4));

    if ($iDateTo>=$iDateFrom)
        array_push($aryRange,date('Y-m-d',$iDateFrom)); // first entry
        while ($iDateFrom<$iDateTo)
            $iDateFrom+=86400; // add 24 hours
    return $aryRange;

$fromDate = '2014-07-24';
$toDate = '2014-07-31';

$dateArray = getAllDatesBetweenTwoDates($fromDate, $toDate);


Output will be :