Posts

Showing posts with the label php

Validate Date PHP

For date validation in PHP Try this and enjoy :) <?php function isValid($date) { $date_format = ' d F Y '; $input =$date;   //say ' 11 February 2013'; $input = trim ($input); $time = strtotime ($input); $is_valid = date ($date_format, $time) == $input; return $is_valid ? 'yes' : 'no'; }

Open color box on Page load

This code working with all frameworks.             Required Latest versions of :-                     1-colorbox.js                     2-jquery.min.js                     2- Download                 < script type = "text/javascript" > var j = jQuery.noConflict(); j( document ).ready( function (){ j.fn.colorbox({width : "685px;" ,overlayClose : false , escKey : false , inline : true , href : "#inline_content" }); j( "#cboxClose" ).remove(); }); < /script>

Safe name of a file by php

 function filename_safe($filename) {     $temp = $filename;      // Lower case     $temp = strtolower($temp);         // Replace spaces with a "_"     $temp = str_replace(" ", "_", $temp);         // Loop through string     $result = "";     for ($i=0; $i<strlen($temp); $i++) {     if (preg_match("([0-9]|[a-z]|_)", $temp[$i])) {     $result = $result . $temp[$i];     }     }     // Return filename     return $result;     }         function safe_filename ($filename) {     $search = array(     // Definition of German Umlauts START     "/ß/",     "/ä/","/Ä/",     "/ö/","/Ö/",     "/ü/","/Ü/",     // Definition of German Umlauts ENDE     "([^[:alnum:]_])" // Disallow: Not alphanumeric...