Posts

Showing posts from February, 2012

How to generate random eight digit number in php?

To random generate the 8 digit code number Simple copy and paste this code in you php file and run the file You can also customize the code <?php                     $chars = "BC0DEFG1HJK3LMO4PQRS5TUW6XYZa7bcdefg8hijklimno9pqrst";                         $res = "";                         for ($i = 0; $i < 8; $i++) {  // you can replace 8 to any number to change the length of code                         $res .= $chars[mt_rand(0, strlen($chars)-1)];                         }                         echo $coupon_code = $res;   ?>

Jquery customizable validation?

Jquery customizable validation Add latest jquery file in the top of the page <script src="http://code.jquery.com/jquery-1.7.1.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() {   $('#submit').click(function() {   alert('sagar');   $(".error").hide();   var hasError = false;   var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;   var emailblockReg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com) (?!aol.com)([\w-]+\.)+[\w-]{2,4})?$/;   var fname = $("#fname").val();   var lname = $("#lname").val();   var Email = $("#email").val();   var password = $("#password").val();   var cpassword = $("#cpassword").val();   var address = $("#address").val();   var zipcode = $("#zipcode").val();   var state = $("#state").val();   var phone = $("#phone").val()

How to add twitter share button in our website?

Simple copy and paste this code to add a twitter link in your website  <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <a href="https://twitter.com/share" class="twitter-share-button"           data-url="Your website URL"           data-via="website"           data-text="content you want to share"           data-related="name"           data-count="none">   tweet </a> Now you can share your your content on twitter.

How to get time difference between two dates in specific format?

If are looking for a time difference in  specific format like : 2min ago, 2 hour ago, 2 week ago, 2 month ago You came right place simply copy and paste this code in you php file and run the file it will return you time , date format according to your need. <?php function getdiffrenceformat($time) {     date_default_timezone_set('Asia/Kolkata');     $mintime = getDifference(date("Y-m-d H:i:s"),$time,'1');     $hourtime = getDifference(date("Y-m-d H:i:s"),$time,'2');     $daystime = getDifference(date("Y-m-d H:i:s"),$time,'3');     $weektime = getDifference(date("Y-m-d H:i:s"),$time,'4');     $monthtime = getDifference(date("Y-m-d H:i:s"),$time,'5');     $yeartime = getDifference(date("Y-m-d H:i:s"),$time,'6');         if($mintime<=60)         {             return $mintime.' min ago';         }         elseif($hourtime<=24)         {  

How to separate url into a embed code of youtube?

how to separate url from a embed code of youtube ? there is a solution for Get url into a  embed code of youtube function getyoutubeVideolink ($code){     $a = array();     $b = array();     $c = array();     $a = explode('src',$code);     $b = explode('frameborder',$a[1]);     $b = explode('frameborder',$b[0]);     $c = explode('"',$b[0]);     return $c[1];     } $embed_code = '<iframe width="420" height="315" src="http://www.youtube.com/embed/GwQMnpUsj8I" frameborder="0" allowfullscreen></iframe>'; $url = getyoutubeVideolink( $embed_code ); echo $url; Now you can use this url in a iframe and where do you want

response.session.access_token is not working during the facebook connect?

JavaScript SDK and OAuth 2.0 Roadmap Facebook has updated JavaScript SDK and OAuth 2.0 Roadmap Due to this reason response.session.access_token is not working So You have make some changes in your Facebook login Function   FB.login(function(response) {                 if(response.session) {                     var access_token = response.session.access_token;                     FB.api('/me', function(response) {                     }                 } }   Your code was like this in facebook login function.   So edit some code and make this problem solved    FB.login(function(response) {                     if (response.authResponse) {                     var accessToken = response.authResponse.accessToken;                     alert(accessToken);                     FB.api('/me', function(response) {                     }                 } } So you have to change response.session to response.authResponse and  access_token to accessToken Done

How to print a response object comes by facebook login in javascript or jquery?

Facebook response return an object So for print the response You can use JSON . stringify () function. You can use this function as mention below alert( JSON . stringify (response)); Example : FB.login(function( response ) {                     FB.api('/me', function( response ) {                   var query = FB.Data.query('select src_big from photo where pid in (select cover_pid from album where owner={0} and name="Profile Pictures")', response.id);                  query.wait(function(rows) {                          alert(JSON.stringify(response));                                });                    }); }