January 23, 2016

htaccess rule for redirect non www to www.


- You can define following two line just for redirect your non www to wwww, If anyone open your site without www like http://domainname.com then its automatically redirect to  http://www.domainname.com,

- See below example:

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


Enjoy :)

January 21, 2016

jQuery data Tables how to set record per page?




- If you want to set 10 records per page on jQuery data Tables then please see below example:

$('#tableID').dataTable( {

  "pageLength": 10

} );

In above example define no of records you want per page on pageLength parameter,

Enjoy!

January 16, 2016

jQuery select chosen validation not working with PHP




- I find best solution for that and its very simple for select chosen validation,

- The jQuery validation ignore default hidden fields,

- Just pass one parameter as per below example like: ignore: hidden:not,

Example!

$(document).ready(function(){
    $('#se;ectid').chosen();
    $('#formid').validate({ ignore: ":hidden:not(select)" });
    $('#validateIt').click(function(){
        if($('#formid').valid())
            alert('This is Valid');
        else
            alert('This is Invalid');
    });
});

Enjoy!

January 7, 2016

PHP - How to send email using Gmail SMTP?



Following example help you to send email using Gmail SMTP with PHP,

You can download PHP mailer function from here GitHub.


require 'PHPMailerAutoload.php';

$from = '<yourname@gmail.com>';
$to = '<sendto@yahoo.com>';
$subject = 'Hello!';
$body = "Hello,\n\nHow are you?";

$headers = array(
    'From' => $from,
    'To' => $to,
    'Subject' => $subject
);

$smtp = Mail::factory('smtp', array(
        'host' => 'ssl://smtp.gmail.com',
        'port' => '465',
        'auth' => true,
        'username' => 'johndoe@gmail.com',
        'password' => 'passwordxxx'
    ));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
    echo('<p>' . $mail->getMessage() . '</p>');
} else {
    echo('<p>Message successfully sent!</p>');
}

Enjoy!

January 3, 2016

PHP - How to get YouTube video image from YouTube URL?




- When I face this problem to display YouTube video image display from URL/link, then I find one solution as below:

- For each YouTube have unique video ID so you can get 5 type of images using that ID,

- Here I explain with example for all type of YouTube images how to display?

1. For video default image but not high resolution of image:

   http://img.youtube.com/vi/<YouTube-Video-Unique-ID>/default.jpg


2. For the high resolution of image use below link:

   http://img.youtube.com/vi/<YouTube-Video-Unique-ID>/hqdefault.jpg


3. For the medium quality of the thumbnail image use below example:

   http://img.youtube.com/vi/<YouTube-Video-Unique-ID>/mqdefault.jpg


4. For the standard version of the image use a link similar to this:

   http://img.youtube.com/vi/<YouTube-Video-Unique-ID>/sddefault.jpg


5. For the maximum resolution of the video thumbnail image use a url like this:

   http://img.youtube.com/vi/<YouTube-Video-Unique-ID>/maxresdefault.jpg

- And one more thing for above all URLs you can also used https instead of http.

Enjoy!

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...