December 16, 2016

Wordpress temporary session to save any message?



If you need to save any error OR success message on wordpress function.php file OR any other file then please follow below steps:

Here I explain with one success message save on function file and display on home page:

function.php

<?php
function myTempFun() {
   if(!session_id()) {
       session_start();
   }
   $_SESSION['my_session_name'] = 'Write here any message';
}
?>

home page template.php

if ( array_key_exists( 'my_session_name', $_SESSION ) ) {?>
    <p><?php echo $_SESSION['my_session_name']; ?></p>
<?php
    unset( $_SESSION['my_session_name'] );
}

After session display also unset that , So when you refresh page then second time that session not displaying.

Enjoy!

December 15, 2016

Freelancer Web Developer From India, Gujarat


All type of  PHP, CMS and Framework development with high coding standard.

Freelancer Web Developer From India, Gujarat.

Hire PHP Developer provides ideal solutions for your requirements.

Contact Me:

https://wiseintro.co/montukhant

http://khantmontu.blogspot.in/p/contact-us.html

Mobile No: 9033665158

Email: montukhant@gmail.com

Skype: montukhant

November 18, 2016

PHP Toolkit retrieve Item Fulfillment record attached to a Sales Order



As the subject says, I would like to be able to retrieve the Item Fulfillment records attached to a Sales Order record, if any, using the PHP Toolkit.

The code below will retrieve the Sales Order and Cash Sale records based on the value of a custom field, but I cannot get it to include an Item Fulfillment record. Any help will be greatly appreciated.


$ts = new TransactionSearch();
$tsb = new TransactionSearchBasic();
$csf = new SearchStringCustomField();
$csf->internalId = '69';
$csf->searchValue = '100000137';
$csf->operator = 'is';
$scfl = new SearchCustomFieldList();
$scfl->customField = array($csf);
$tsb->customFieldList = $scfl;
$ts->basic = $tsb;
$request = new SearchRequest();
$request->searchRecord = $ts;
$searchResponse = $service->search($request);

Enjoy!

October 1, 2016

JavaScript localstorage with good example



In javascript using localstorage you can simply save any single OR array value same like work as a PHP session.


There is a simple solution though, and that’s to use local storage.

The good news is to stored any data to computer so when page reload then you can get data back from localstorage.


WHAT IS EXACT MEANING OF LOCAL STORAGE?

  • Local Storage: stores data with no expiration date and this is the one we will be using because we want our to-do’s to stay on the page for as long as possible.
  • Session Storage: only saves the data for one session so if the user closes the tab and reopens it all their data will be gone.

BELOW ARE SOME EXAMPLE FOR SET VALUE, GET VALUE AND CLEAR VALUE FROM LOCAL STORAGE

To set item into local storage:

localStorage.setItem('username', 'admin');

To get value from local storage:
localStorage.getItem('username');
Output: admin

To clear any value from local storage:
localStorage.removeItem('username');


Enjoy!





September 5, 2016

PHP - MariaDB database connection.



Hello everyone, this this simple way to connect MariaDB with PHP,

Here I explain with simple example.

Example:

<?php
$connection=mysqli_connect("hostname","username","password");
$db = mysqli_select_db("databasename");
if (mysqli_connect_errno())
{
echo "Connection Failed with MariaDB:" . mysqli_connect_error();
}
?>

Enjoy!


September 4, 2016

MySQL select query to inner join two table in single field.




MySQL select Query to inner joint two tables on single field.

SELECT CASE

WHEN STATUS_FLAG=1 THEN (select id from table2 where id=TABLE1.F_ID)

ELSE (select id from table3 where id=TABLE1.F_ID)

END


FROM TABLE1

MySQL select query with case and when condition.



Here I explain CASE and WHEN condition with MySQL select query.

MySQL Example:

SELECT CASE

          WHEN STATUS_FLAG=1 THEN ‘Yes’ ELSE ‘No’

           END AS STATUS_FLAG


FROM TABLE1


Enjoy!

August 1, 2016

PHP - Call to undefined method PDF_HTML::FPDF()..



Before one day I realize this error and I find a simple solution, See below:

On included file 'html2pdf.php' you should just rename one function name as per below:

Approx line no: 52

1. Line no: 49
Replace function PDF_HTML with function __construct

2. Line no 52
Replace $this->FPDF with parent::__construct

Enjoy!

July 18, 2016

How to view web site in fullscreen using HTML5 and jQuery?


Please follow below step and refer this link for more help.

1: First include following two JS in header part between <head> tab,

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script src="//use.fontawesome.com/aa03aaad2f.js"></script>

2: HTML code for just link

<a href="javascript:;" class="fullscreen "><i class="fa fa-arrows-alt"></i> View Fullscreen</a>
 

3: jQuery API code
 
$(".fullscreen-toggle").on("click", function() {
    document.fullScreenElement && null !== document.fullScreenElement ||
    !document.mozFullScreen && !document.webkitIsFullScreen ?
    document.documentElement.requestFullScreen ?
    document.documentElement.requestFullScreen() :
    document.documentElement.mozRequestFullScreen ?
    document.documentElement.mozRequestFullScreen() :
    document.documentElement.webkitRequestFullScreen &&
    document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):
    document.cancelFullScreen ? document.cancelFullScreen() :
    document.mozCancelFullScreen ? document.mozCancelFullScreen() :
    document.webkitCancelFullScreen && document.webkitCancelFullScreen()
});
 
For more details click Here!

Demo

Enjoy!



July 14, 2016

New PHP 7 Alpha for version released this week PHP 7.1.0



One good news for  PHP Fans,

The latest Alpha for PHP 7 has been released this week. PHP 7.1.0 Alpha 3 is available immediately.

Also this week, has your company decided it's time to "do community"? Get some tips on how to build a community presence.

We take a look at the brilliant tiny computer Raspberry Pi, and how to use it to power projects with PHP.

Plus Adam Culp and Cal Evans gave a question and answer session, from a conference organiser's perspective, on how conference talks are selected.

And finally, PHP South Africa has been announced, taking place over three days in September, in Johannesburg. Early Bird tickets are currently on sale.

Click Here for read more.

Enjoy!

Single SQL query with GROUP_CONCAT, DISTINCT and SEPARATOR.



Here is example for use GROUP_CONCAT, DISTINCT and SEPARATOR in single sql query,

Example:

SELECT group_concat(distinct (id) SEPARATOR ', ') AS ID FROM (tablename) WHERE 1=1

Enjoy!

July 13, 2016

Smarty - Display php variable on tpl file.



Hi every one after long time I come back on my blog,

Here some example to display PHP variable on Smarty template (.tpl) file:

1. Simple variable
{$variablename}

2. For count array
{count($arrayVariable)}

3. For if condition
{ if $variable==1}......{/if}

4. For foreach loop on template file
{ foreach $res as $key}
   {$key.id}
   {$key.name}
{/foreach}

Enjoy!

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!

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...