January 31, 2016

htaccess if site open with www and its redirect without www


- If you want to open your site with out www then just simple write 2 lines in you .htaccess file and upload it in your root server.

For example:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.domainname.com [NC]

RewriteRule ^(.*)$ http://domainname.com/$1 [L,R=301]

Note: In above example replace your currect domainname. If you have SSL certificate then used https:// instead of http://.


- And if you want used force www on without www domain name,

- Then just below 2 lines in your .htaccess file and upload in your root server.

For example:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^domainname.com [NC]

RewriteRule ^(.*)$ http://www.domainname.com/$1 [L,R=301,NC]

Note: In above example replace your currect domainname. If you have SSL certificate then used https:// instead of http://.

If you have any question related any .htaccess rules issue then please comment me here I will you to solved that.

Enjoy!

January 28, 2016

AngularJs ng-click not working with datatable




Yes, normally datatable Ajax file call outside of AngularJs folder structure, If you define ng-click there then it’s not working in AngularJs.

Finally I find a best solution for AngularJs ng-click working with datatable.

Below is simple example for any Edit / Delete link:

<button onclick=\"angular.element(this).scope().recordEdit('".$id."')\">Edit</button>

In above example recordEdit is function which you can used in main js like $scope.recordEdit() function.


Enjoy!

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...