Pages

Wednesday, July 26, 2017

Send EMAIL with PHPMailer using SMTP in bluehost

<?php
set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', 'On');
require_once "Phpmailer/PHPMailerAutoload.php";


$mail = new PHPMailer(true);
$mail-> IsSMTP();
$mail->Host = "box605.bluehost.com";
$mail->SMTPAuth = true;
$mail->Username = "email@domain.com";
$mail->Password = 'password';
//$mail->SMTPSecure = 'tls'; //TLS
$mail->Port = 26;

//$mail->From = "";//$mail->Username; //mandatory and identical to Username property
$mail->setFrom($mail->Username, 'Mailer Test');
$mail->addReplyTo('email@domain.com');

$mail->Subject = "Hello message";
$mail->Body = "Body goes here...";
$mail->addAddress('zakeerio25@gmail.com');



if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}

?>

Sunday, April 2, 2017

How to get Distinct Years using DATE_FORMAT() In the mysql database table

$rs =  mysql_query("SELECT DISTINCT(DATE_FORMAT(date_paid,'%Y') ) as mindate FROM purchase ORDER BY mindate ASC");
     
        ?>
       
        <select name="dy">
       <?php

       while( $minDate = mysql_fetch_array($rs) ) {
        $seldm = $_GET['dy'] == $minDate['mindate'] ? 'selected="selected"' : '';
        echo '<option value='.$minDate['mindate'].' '.$seldm. '>'.$minDate['mindate'].'</option>';
       }
       ?>
        </select>

Wednesday, February 22, 2017

Showing the calendar in jquery with month and year

Practice with Showing the calendar in jquery and showing the month select and year select.

 

$( "#datepicker" ).datepicker({
dateFormat: 'dd-mm-yy',
yearRange: "1990:2050",
            changeMonth: true,
            changeYear: true
        });

Tuesday, February 21, 2017

How to Encode and Decode Strings with Base64 in JavaScript

How to Encode and Decode Strings with Base64 in JavaScript

Internet Explorer 10 and above



// Define the string var string = 'Hello World!'; // Encode the String var encodedString = btoa(string); console.log(encodedString); // Outputs: "SGVsbG8gV29ybGQh" // Decode the String var decodedString = atob(encodedString); console.log(decodedString); // Outputs: "Hello World!"

Friday, February 3, 2017

Remove Index.php from URL in codeigniter

How to Remove Index.php from URL in codeigniter

Just Copy and paste this data in your .htaccess on root folder of your project file then run your project.

RewriteEngine On

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]

#When your application folder isn't in the system folder

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Thursday, February 2, 2017

Upload file from url in PHP via Curl




 $ch = curl_init();
            $source = 
'http://website.com/filename.jpg';
            $path_parts = pathinfo('http://website.com/filename.jpg');
            curl_setopt($ch, CURLOPT_URL, $source);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $data = curl_exec ($ch);
            curl_close ($ch);

           // Your File Path and Filename here

            echo $destination = "./fileuplods/".$path_parts['filename'].'.'.$path_parts['extension'];
            $file = fopen($destination, "w+");
            fputs($file, $data);
            fclose($file);

Saturday, January 14, 2017

Smooth Scroll for menu in Onepage site

Smooth Scroll for Onepage site


$(function() {
   $('ul li a[href*="#"]:not([href="#"])').click(function() {
   if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
     var target = $(this.hash);
     target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
     if($(window).width()>=768){
       if (target.length) {
         $('html, body').animate({
           scrollTop: target.offset().top - 90
         }, 800);
         return false;
       }
     }
     else{
       if (target.length) {
         $('html, body').animate({
           scrollTop: target.offset().top - 50
         }, 800);
         return false;
       }
     }
   }
   });
 });