Ads Inside Post

Search in This Blog

File upload in CodeIgniter

Problem:

How to upload file in CodeIgniter?
You can simply use $_FILES array to upload image. But if you want to use CodeIgniter library to upload file, then how can you achieve this? 

Solution:

You can use $this->load->helper('form'); to generate form.
After that configure using $config[], set this $config[] same as $this->load->library('upload', $config);
and upload like this
$this->upload->do_upload('transporter_image');

Error may occur during file upload so you can get error list by using

$his->upload->display_errors());
If file uploaded the get the information by this method:
$this->upload->data();

Example:

VIEW FILE
transporter_form.php
<html>
<head>
<title>File uploading in CodeIgniter</title>
</head>
<body>
<?php echo form_open_multipart('Transporter/transporterlist/');?>
<input type="file" name="transporter_image" size="20" />
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
============================================
CONTROLLER FILE
Transporter.php
<?php
class Transporter extends CI_Controller {
        public function __construct()
        {
                parent::__construct();
                $this->load->helper('form');
        }

        public function index()
        {
                $this->load->view('transporter_form', array('error' => ' ' ));
        }

        public function transporterlist ()
        {
        $config['upload_path']          = './images/transporter/';
            $config['allowed_types']        = 'gif|jpg|png';
            $config['max_size']             = 100;

            $config['max_width']            = 1024;
            $config['max_height']           = 768;
        $config['file_name']           = 'file_name.jpg';// set file name here
        $this->load->library('upload', $config);
        if(!$this->upload->do_upload('transporter_image')) {
                    $data['imgerror']= array('error' => $this->upload->display_errors());
        } else {
                    $data['imgsuccess'] = 'Image uploaded';//array('success' => $this->upload->data());
        }
        $this->load->view('successpage',$data);
        }
}
?>
==============================================
VIEW FILE
successpage.php
<html>
<head>
<title></title>
</head>
<body>
<h3>Your file was successfully uploaded!</h3>
<?php
    if(isset($imgsuccess)){
        echo $imgsuccess;
    }
?>

<ul>
<?php
if(isset($imgerror)) {
    foreach ($imgerror as $item => $value):?>
        <li><?php echo $item;?>: <?php echo $value;?></li>
<?php
    endforeach;
}
?>
</ul>
</body>
</html>








Prevent XSS in CodeIgniter

Problem:

How to prevent XSS Cross Site Scripting in CodeIgniter

Solution:

use $this->security->xss_clean($input_data); method
OR
set $config['global_xss_filtering']=TRUE;

Example:

$input_data = $this->security->xss_clean($input_data);
or add this line in config.php file
$config['global_xss_filtering'] = TRUE;

Binding Where IN Clause in CodeIgniter

Problem:

How to bind multiple and single value in where IN sql clause using CodeIgniter

Solution:

Pass array variable in query

Example:

Passing single numeric value using array.

$sql = "SELECT * FROM tbl_name WHERE id IN ? AND nm = ? AND code = ?";
$this->db->query($sql, array(array(1), 'nm123', 'c123'));

Passing multiple numeric value using array.
$sql = "SELECT * FROM tbl_name WHERE id IN ? AND nm = ? AND code = ?";
$this->db->query($sql, array(array(1, 2, 3), 'nm123', 'c123'));

Passing single string value using array.
$sql = "SELECT * FROM tbl_name WHERE id IN ? AND nm = ? AND code = ?";
$this->db->query($sql, array(array('a1'), 'nm123', 'c123'));

Passing multiple string value using array.
$sql = "SELECT * FROM tbl_name WHERE id IN ? AND nm = ? AND code = ?";
$this->db->query($sql, array(array('a1', 'a2', 'a3'), 'nm123', 'c123'));

load model in view codeigniter

Problem:

How to load model in CodeIgniter view? It is not a good idea to load model in view, but sometime it is a requirement to load model in view.

Solution:

Create the instance of CodeIgniter as below:
$ci_inst =&get_instance();

Then load your model as below:
$ci_inst->load->model('model_name');

now you can access model as below:
$rs_truck=$ci_inst->model_name->function_method_name(parameter);

Example:

$ci_inst =&get_instance();
$ci_inst->load->model('truck_model');
$rs_truck=$ci->truck_model->get_trucks_by_transporter_id(1);

Email Blaster

Email Blaster
*Features
- Send unlimited emails.
- Send test email, so you can see your email format and looks.
- Show real time progress in counting sent emails.
- Show progress in percentage(%)
- Send email both format Text and HTML format.
- Alternate Solution of Cron Job(Less feature).
- Alternate Solution of SQL Agent Job(Less feature).
- Solution of Script Timeout.






















































Image Cropper

Image Cropper
How to use?
1- Click to "open" button & select image file.
2- Drag & select the portion of image.
3- Click on "select" button.
4- click on "save" button.
 
Image Cropper

Download here




























Text to speech

Text to speech



Text to speech












Download here:
Download











Custom library in CodeIgniter

Custom library in CodeIgniter:

CodeIgniter is a MVC PHP Framework. Do you know this framework is very fast PHP framework. It is designed to create a dynamic, flexible & SEO friendly web application.
Now days CodeIgniter is very famous MVC framework. In past time when you work in Core PHP with OOP; you have developed own custom library which have many utilities functions which you uses in different Projects. This custom library save your time and remove complexity.

Now you are moving to modern programming languages like CodeIgniter  framework. Now the question is how to use that custom library in this CodeIgniter framework?


See below class with having functions which is your custom library:
<?php
// Class name is "Myclass". but you can change it with any name
class Myclass {
   // Declare local variable
   var $temp;
   // This is constructor of "Myclass" here you can initialize local variables etc.
    public function __construct(){
       // set local variable value with single space.
       $this->temp='';
    }
 
   // this is method will call after delete record in CodeIgniter Controller
    public function message_del() {
        // Add here your usefull code
        $this->temp='    Record Deleted.';
        return $this->temp;
    }
 
// this is method will call after edit record in CodeIgniter Controller
    public function message_edit() {
        // Add here your usefull code
           $this->temp='    Record Edited.';
        return $this->temp;
    }

   // this is method will call after add record in CodeIgniter Controller
    public function message_add() {
            // Add here your usefull code
        $this->temp='    Record Added.';
        return $this->temp;
    }
}
?>


Now how to use above class in CodeIgniter?  Follow below steps o how to use.
//Create Myclass.php file in codeigniter "application\libraries\"

//Myclass.php
<?php
// this is default CodeIgniter code Do not delete it
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Myclass {
   // Declare local variable , note that $temp variable will return from it's class's methods
   var $temp;
   var $CI;
   public function __construct(){
      // set CodeIgniter instance object here. but it is not necessary.
       $this->CI =&get_instance();
       // set local variable value with single space.
       $this->temp='';
    }
     // this is method will call after delete record in CodeIgniter Controller
    public function message_del() {
        // Add here your code which delete record from mysql database.
        $this->temp='    Record Deleted.';
        return $this->temp;
    }
 
// this is method will call after edit record in CodeIgniter Controller
    public function message_edit() {
         // Add here your code which edit record in mysql database.
           $this->temp='    Record Edited.';
        return $this->temp;
    }

   // this is method will call after add record in CodeIgniter Controller
    public function message_add() {
            // Add here your code which add record in mysql database.
        $this->temp='    Record Added.';
        return $this->temp;
    }
}
?>

Now how to use above class in any controller class
Create Category.php controller file in "application\controllers\" folder
Category.php


<?php

// this is default CodeIgniter code Do not delete it
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// This is the Controller class it must always extends with  CI_Controller
class Category extends CI_Controller {

// This the default constructor with same name as Category class
    function Category() {
        //it is necessary to call parent class's (CI_Controller) constructor
        parent::__construct();

        // this is the your Myclass class in Myclass.php file in "application\libraries\" folder
        // this is the way to load your custom class. Make sure it should be small case letter
        $this->load->library('myclass');
    }
    public function index() {
        // use own logic here, you can make empty it.
    }
    // suppose you want to use MyClass.php >message_add method here
    public function addrecord() {
        // this is the way to calling method message_add()
         $data['ans']=$this->myclass->message_add();
//now load "result_view" with ans data
        $this->load->view('result_view',$data);
    }
    // suppose you want to use MyClass.php method message_edit() here
    public function editrecord() {
        // this is the way to calling method message_edit()
        $data['ans']=$this->myclass-message_edit();
//now load "result_view" with ans data
       $this->load->view('result_view',$data);

    }
    // suppose you want to use MyClass.php method message_del() here
    public function deleterecord() {
        // this is the way to calling method message_del()
         $data['ans']=$this->myclass-message_del();
        //now load "result_view" with ans data
        $this->load->view('result_view',$data);
    }   
}
?>



Now how to use above class in any controller class
Create 
result_view.php  view file in "application\views\" folder
result_view.php

<?php
//now access the variable  "$ans"  which  set in  $data['ans']=$this->myclass-message_del();  
// and load it in the view as $this->load->view('result_view',$data);

if(isset($ans)) {
          echo $ans;

       }
?>


Fatal error: Call to a member function num_rows() on a non-object in

Problem:

While working with CodeIgniter you can get this "Fatal error: Call to a member function num_rows() on a non-object in...." error. You can also surprise that every thing is okay and every thing is okay in your sql.

Solution:

Some time you used different my sql Database name in local and production server, and you have mentioned wrong database name in your config.php file, So just verify the Database name and this error will gone.




Image Combiner


Combine all images from selected folder into one image.
This is a Free desktop software to combine multiple images into one single image.
There are no limit to combine , so you can combine unlimited images.
You need to select the folder where all images are existing.
This tool automatically get the highest width of image.














Download Image Combiner




Change Search in This Blog size

Problem:

If you have a blog owner in blogger and used the "Search in This Blog" widget, you can see this size is very large and taking lot of spaces in your blog

Solution:



Use below code at the end of your blogger XML file

<script>
function r_search() {
var r_place_s=&quot;h2&quot;;
var r_place_t=&quot;h5&quot;;
var Attribution1=document.getElementById(&quot;CustomSearch1&quot;);
var Attribution1_html=Attribution1.innerHTML;
var regex = new RegExp( &#39;(&#39; + r_place_s + &#39;)&#39;, &#39;gi&#39; );
Attribution1.innerHTML=Attribution1_html.replace( regex, r_place_t );
}
r_search();
</script>

Parse error syntax error unexpected end of file

Problem:

While working with PHP you may get this error
"Parse error: syntax error, unexpected end of file"

Solution:

If you missed the proper php tag <?php and used as below tag without configuration short tag
<?

?>
Then you will get the "Parse error: syntax error, unexpected end of file" error message

Example:

So replace below tag
<?
?>

To

<?php

?>

Get Internet Explorer Browser Urls lists


Get Internet Explorer Browser Urls lists


Get Internet Explorer Browser Urls lists









Download here






Get Internet Explorer Browser Urls list

Get Internet Explorer Browser Urls list


Get Internet Explorer Browser Urls lists









Download here









Lazy load image

If your site is loading slow then then main causes could be heavy images. So if you remove those images then your site load fast. but if those images are the main features of your product or web site then you will not remove those images. So what will you do?
Load those images one by one on demand then it will make difference when loading site.
So the solution is lazy load image will help you to load your site fast.

To implement lazy load image you need to download jquery.js and jquery.lazy.js from jquery site

I have made three methods to load image lazy, Use one method from below 3 methods:
// Method 1
    jQuery(document).ready(    function() { jQuery("img.lazy").lazy(    {
                                                                    effect: "fadeIn",
                                                                    effectTime: 1500 ,
                                                                    enableThrottle: true,
                                                                    throttle: 250
                                                                    }
                                                                );
                                       }
                          );

// Method 2
    //jQuery(document).ready(function() { jQuery("img.lazy").lazy({ effect: "slideIn", effectTime: "slow" }); });

//Method 3
    //jQuery(document).ready(function() { jQuery("img.lazy").lazy({ effect: "fadeIn", effectTime: 1500 }); });


 Use in HTML as below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
  <script type="text/javascript" src="jquery.js"></script> 
  <script type="text/javascript" src="jquery.lazy.js"></script>
  <script>
    jQuery(document).ready(    function() { jQuery("img.lazy").lazy(    {
                                                                    effect: "fadeIn",
                                                                    effectTime: 1500 ,
                                                                    enableThrottle: true,
                                                                    throttle: 250
                                                                    }
                                                                );
                                       }
                          );
    // alternative 1
    //jQuery(document).ready(function() { jQuery("img.lazy").lazy({ effect: "slideIn", effectTime: "slow" }); });
    // alternative 2
    //jQuery(document).ready(function() { jQuery("img.lazy").lazy({ effect: "fadeIn", effectTime: 1500 }); });
  </script>
</head>
<body>
<img class="lazy" data-src="1.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="2.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="3.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="4.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="5.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br /><img class="lazy" data-src="23.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="24.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="25.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />

...... LOAD MORE IMAGES HERE ....
...... LOAD MORE IMAGES HERE ....
...... LOAD MORE IMAGES HERE ....
...... LOAD MORE IMAGES HERE ....


<img class="lazy" data-src="26.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="27.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="28.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="29.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="30.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="31.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br />
<img class="lazy" data-src="32.jpg" src="" border="0" alt="Lazy Image" /><br/><br /><br/><br /><br/><br /><br/><br /></body>
</html>

Multiple word find replace in file

Problem:
Suppose you have many more files which having 5 words as below:

Alien
Time
Options
Customs
Robot

each one you want to replace with certain word, then what you will do?
For this you need to manually open each file and find replace operation many time.

You can make your task by this free Extended Find And Replace Utility Software .
By this you do Multiple(5 Times) Find And Replace Operations.

Multiple word find replace in file




















It is Also Create BackUp Of Old Files With Current Date.
So You can Use That For Further Use.
No Worries, It Will Not Stop When it Find The Hidden and ReadOnly Files
It Will Replace Those Too.
Enjoy :)

Thanks For Using It.
Download Multiple word find replace in file free software here



































Load javascript file dynamic

How to Load javascript file dynamic by button click.

1) First create a javascript file "my_script.js" with below contents:

"my_script.js"
function ss(){
      alert("aa");  
}

2) Create a test.html file with below contents:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function my_dynamic_js(js_file_name) {
var head = document.getElementsByTagName("head")[0];
var sscript = document.createElement("script");
sscript.type = "text/javascript";
sscript.src = js_file_name;
head.appendChild(sscript);
}
</script>
</head>
<body>
<input type="button" value="load" onClick="my_dynamic_js('my_script.js')">
<input type="button" value="show" onClick="ss()">
</body>
</html>

3) now open test.html file and click on "load" button then after click on "show" button

bottom to top scroll in html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
#back-to-top {
     position: fixed;
     bottom: 30px;
     top: 350px;
}
#back-to-top img{
    cursor:pointer;
}
</style>
<script language="javascript" src="jquery-1.10.2.js" type="text/javascript"></script>
</head>
<body>
<h1>Back To Top</h1>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p><p>fsdfsdfsdf</p>
<div style="height:1000px"></div>
<span id="back-to-top"><img id="bus" src='bus.gif'/></span>
</body>
<script type="text/javascript">
        $(document).ready(function () {
            $("#back-to-top").hide();
            $(window).scroll(function () {
                if ($(window).scrollTop() > 200) {
                    $('#back-to-top').fadeIn();
                } else {
                    $('#back-to-top').fadeOut();
                }
            });
              $('#back-to-top img').click(function () { 
               var body = $("body, html");
               body.animate({scrollTop :0}, '1500',function(){ });
            });
        });
    </script>
</html>

jQuery Up Button

jQuery Up Button
<!-- Load jQuery -->
      <script type="text/javascript" src="jquery-1.6.3.min.js"></script>
<!-- jQuery Up Button -->
<script type="text/javascript">//<![CDATA[
$(document).ready(function(){$("#back-top").hide();$(function(){$(window).scroll(function(){if($(this).scrollTop()>2000){
 $('#back-top').fadeIn();}else{$('#back-top').fadeOut();}});$('#back-top a').click(function(){$('body,html').animate({scrollTop:0},800);return false;});});});
//]]></script>

<p id="back-top" style="display: block; border-radius: 15px 15px 15px 15px;
    display: block;
    height: 108px;
    margin-bottom: 7px;
    transition: all 1s ease 0s;
    width: 108px;"><a href="#top"><span></span> Back to top </a>
          
         </p>
       
         <p>fhjdsfhdsfjdsfhjdsfhdsfdsfds</p>
         <p>fhjdsfhdsfjdsfhjdsfhdsfdsfds</p>
         <p>fhjdsfhdsfjdsfhjdsfhdsfdsfds</p>
         <p>fhjdsfhdsfjdsfhjdsfhdsfdsfds</p>
         <p>fhjdsfhdsfjdsfhjdsfhdsfdsfds</p>

Google transliteration english to hindi

Google transliteration English to Hindi

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://www.google.com/jsapi">
</script>
<script type="text/javascript">
// Load the Google Transliteration API
google.load("elements", "1", {
            packages: "transliteration"
          });
function onLoad() {
    var options = {
        sourceLanguage:
                google.elements.transliteration.LanguageCode.ENGLISH,
            destinationLanguage:
                [google.elements.transliteration.LanguageCode.HINDI],
            shortcutKey: 'ctrl+g',
            transliterationEnabled: true
    };
    // Create an instance on TransliterationControl with the required options.
    var control =new google.elements.transliteration.TransliterationControl(options);
    // Enable transliteration in the textbox with id 'transliterateTextarea'.
        control.makeTransliteratable(['firstName']);
        control.makeTransliteratable(['lastName']);
      }
      google.setOnLoadCallback(onLoad);
      </script>
</head>
<body>
<input type="text" autocomplete="OFF" class="tb4" id="firstName" name="firstName">
<input type="text" autocomplete="OFF" class="tb4" id="lastName" name="lastName">
</body>
</html>

Latitude Longitude in JavaScript by city

How to find Latitude and Longitude in JavaScript by city name?
You can easily implement in any framework like Codeigniter, Laravel, CakePHP or any other Framework.

Use below code:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
function getLatLong() {
    var geocoder = new google.maps.Geocoder();
    var address = "New Delhi";//document.getElementById("address").value;
    geocoder.geocode( { 'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
       latitude = results[0].geometry.location.lat();
       longitude = results[0].geometry.location.lng();
       //alert(results[0].geometry.location.lat());
       //alert(results[0].geometry.location.lng());
       $("#locInfo").html("latitude="+latitude+" longitude="+longitude);
      }  else {
      }
    });
}
getLatLong();
</script>
<div id="locInfo" ></div>

Send email using javascript

<html>
<script>
function mailpage(){
    var a=encodeURIComponent("http://agalaxycode.blogspot.in/");
    mail_str="mailto:?subject=This is interest for you: ";
    mail_str+="&body=Find interesting code in javascript: ";
    mail_str+=". %0A%0AYou can view it at, "+a;
    location.href=mail_str;
}
mailpage();
</script>
</html>

Gauge chart in Google Chart

How to implement Google Gauge chart. The most important things is that how to change it's needle alternate with some interval. I have made the code that will change Gauge Google Chart's needle alternate interval.


Gauge chart in Google Chart











EXAMPLE - 1
--------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
How to use Gauge chart and how to change needle frequently interval.
if this code is now show the chart then remove above two lines of <!DOCTYPE tag and <html tag and use listed below tags:
1- <html>  2- <head>
-->
  <head>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
      google.load('visualization', '1', {packages: ['gauge']});
    </script>
    <script type="text/javascript">
    var gauge;
    var gaugeData;
    var gaugeOptions;
    function drawGauge() {
      gaugeData = google.visualization.arrayToDataTable([['Engine', 'Torpedo'], [120, 80]]);
      gauge = new google.visualization.Gauge(document.getElementById('gauge'));
      gaugeOptions = {
          min: 0,
          max: 280,
          yellowFrom: 200,
          yellowTo: 250,
          redFrom: 250,
          redTo: 280,
          minorTicks: 5
      };
      gauge.draw(gaugeData, gaugeOptions);
    }
      function changeTemp(dir) {
        //gaugeData.setValue(0, 0, gaugeData.getValue(0, 0) + dir * 25);
      //gaugeData.setValue(0, 1, gaugeData.getValue(0, 1) + dir * 20);
      gaugeData.setValue(0, 0, Math.floor((Math.random()*100)+1));
      gaugeData.setValue(0, 1, Math.floor((Math.random()*100)+1));
      gauge.draw(gaugeData, gaugeOptions);
    }
      setInterval("changeTemp(1);",1000);
    google.setOnLoadCallback(drawGauge);
    </script>
  </head>
  <body style="font-family: Arial;border: 0 none;">
    <div id="gauge" style="width: 300px; height: 300px;"></div>
  </body>

</html>



EXAMPLE - 2

--------------------
<html>
  <head>
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
    <script type='text/javascript'>
      google.load('visualization', '1', {packages:['gauge']});
      google.setOnLoadCallback(drawChart);
    
      function drawChart() {
      setInterval("docharts();",4000);
      }

 function docharts(){
var data = google.visualization.arrayToDataTable([
          ['Label', 'Value'],
          ['Memory', Math.floor((Math.random()*100)+1) ],
          ['CPU', Math.floor((Math.random()*100)+1) ],
          ['Network', Math.floor((Math.random()*100)+1)]
        ]);

        var options = {
          width: 400, height: 120,
          redFrom: 90, redTo: 100,
          yellowFrom:75, yellowTo: 90,
          minorTicks: 5,
 animation:{
        duration: 5000
      }
        };
        var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
        chart.draw(data, options);
 }
    </script>
  </head>
  <body>
    <div id='chart_div'></div>
  </body>

</html>

Generate excel file in jsp java quickly

When you want to generate excel file in jsp java then you have lot of options,
for ex: jexcelapi, Apache POI,other paid library.
The problem is that the file; first will be created on hard disk then after read it and download to the user’s system.
We all know that the .csv files open in excel software, so we can generate .csv file without any third party library.
It is very simple, quickly, fast and easy to use.

Use listed below code.

showdata.jsp
============================================================
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.StringTokenizer" %>
<%
// made cdb connection here
PreparedStatement psTestUser = conn.prepareStatement("SELECT *from emp");
ResultSet rsTestUser=psTestUser.executeQuery();
String test_login_id,skills_text,desig_text;
ArrayList<String> l1 = new ArrayList<String>();
l1.add("Login,Skills,Design.");
%>
<body>
<a href="download_excel.jsp">download_excel</a>
<table width="100%"  height="600" align="left" border="0">
  <tr>
    <td><strong>User Name</strong></td>
    <td><strong>Designation</strong></td>
    <td><strong>Skills</strong></td>
  </tr>
<%
while (rsTestUser.next()){
%>
  <tr>
    <td><%=rsTestUser.getString("login") %></td>
    <td><%=decryptA(rsTestUser.getString("skills")) %></td>
    <td><%=rsTestUser.getString("design") %></td>
  </tr>
  <%
StringBuilder sb=new StringBuilder();
sb.append(rsTestUser.getString("login")+","+rsTestUser.getString("skills")+",");
sb.append(decryptA(rsTestUser.getString("design")));
l1.add(sb.toString());
}
session.setAttribute("listResult",l1);
%>
</table>
</body>
</html>
<%
// close database connection here
%>


download_excel.jsp
=========================
<%@ page import="java.util.ArrayList"%>
<%
response.setContentType("application/csv");
response.setHeader("content-disposition","filename=test.csv");
ArrayList<String> list = (ArrayList<String>)session.getAttribute("listResult");
for(int i = 0; i < list.size(); i++) {
    String myString = (String)list.get(i);
    out.println(myString);
}
out.flush();
out.close();
%>

MPDF not inserting image in pdf

You may face this problem while working with MPDF when you generate pdf file. this is due to mpdf is not accept full url of image.
for example this will no work:
"http://3.bp.blogspot.com/-koLvN8B-fF0/VBHRKqZ6xUI/AAAAAAAAABQ/oiVeLnXfp2E/s1600/video-watermark.jpg"

to overcome this problem you need to download that image in your server and use relative path while generating pdf. for example if your site name is : http://agalaxycode.blogspot.in/
then you need to create a folder "images" and save different name image from download  "http://3.bp.blogspot.com/-koLvN8B-fF0/VBHRKqZ6xUI/AAAAAAAAABQ/oiVeLnXfp2E/s1600/video-watermark.jpg". suppose you have downloaded and saved it with the name "aa.jpg" in "images" foler.
After that use this relative path in MPDF "images/aa.jpg".
MPDF uses relative path rather than absolute path

mysqli stmt return result

How to return result from mysqli stmt prepare and bind_param statement.
Please note that you must install  MySQL Native Driver (mysqlnd) driver to use get_result();


DBClient.php

<?php
//error_reporting(E_ALL ^ E_DEPRECATED);
class DBClient {
var $host,$db,$user,$pass;
var $mysqli,$isDBConnect;
function __construct() {
    $this->host = "localhost";
    $this->db = "mydb";
    $this->user = "root";
    $this->pass = "pass";
    try {
          $this->mysqli = new mysqli($this->host, $this->user, $this->pass,$this->db );
        if ($this->mysqli->connect_error) {
            die('Error : ('. $this->mysqli->connect_errno .') '. $this->mysqli->connect_error);
        }
    } catch(Exception $ee) {
        $this->link=false;
           $this->isDBConnect=false;
    }
}

public function autocommit_false() {
    $this->mysqli->autocommit(FALSE);  
}

public function commit() {
    $this->mysqli->commit();  
}

public function rollback() {
    $this->mysqli->rollback();
}
public function close() {
    $this->mysqli->close();
}

}
?>


Part_Wise_Class.php
<?php
class Part_Wise_Class {  
    public function part_wise_get_part_nm($class_id,$subject_id) {
        $ssql = "SELECT part_id,part_nm from part_info WHERE class_id =? and subject_id=?";
        $db=new DBClient();
        $stmt = $db->mysqli->stmt_init();
        $stmt = $db->mysqli->prepare($ssql);
        $stmt->bind_param("ii",$class_id,$subject_id);
        $stmt->execute();
        $result = $stmt->get_result();
        $db->close();
        return $result;
   }  
}
?>



test.php
<?php
include_once("DBClient.php");
include_once("Part_Wise_Class.php");  
$part_wise=new Part_Wise_Class();
$class_id=$_GET['class_id'];
$subject_id=$_GET['subject_id'];
$result=$part_wise->part_wise_get_part_nm($class_id,$subject_id);
$rows = array();
while ($row = $result->fetch_array(MYSQLI_BOTH)) {
            echo $row['part_id'];
}
?>

Php json and jquery

How to use PHP, JSON and JQUERY

It is very simple to use PHP, JSON and JQUERY. for this you needed to create two files.
One file is "index.html", second file is "util.php" and this file the class file "DBClient.php" that will responsible for mysql database connection and return result according the sql query.
index.html file call the util.php using jquery ajax metod. and util.php is calling the DBClient.php and create it's object and return the result. the result will parse in index.html and parse it.




index.html

<input type="button" class="button" value="get value" id="btn1" />
<script language="javascript" type="text/javascript">
$("#btn1").click(function() {
    $.ajax({
    type: 'POST',
    url: 'util.php',
    data: { para1: 'city' },
    dataType: 'json',
    success: function (data) {   
        $.each(data.class_info, function(idx, obj) {
            alert(obj.city_name+"===="+obj.city_id);
        });
    }
});  
});
</script>

// you can also use below code,but then you will use different jquery code as below:
 //print  json_encode($rows);
// $.each(data, function(idx, obj) {
//           alert(obj.city_name+"===="+obj.city_id);
//        });util.php

<?php
include_once("DBClient.php");

if(isset($_POST['para1'])) {
$num_rows =0;
$db=new DBClient();
// the "city" table holding the columns "city_id" and "city_name"
$rs_qlist=$db->exeQueryi("select *from city");
$rows = array();
while($r = mysqli_fetch_assoc($rs_qlist)) {
    $rows[] = $r;
}
print ' { "class_info" : ' . json_encode($rows) . ' } ';
}
?>

// you can also use below code,but then you will use different jquery code as below:
 //print  json_encode($rows);
// $.each(data, function(idx, obj) {
//           alert(obj.city_name+"===="+obj.city_id);
//        });


DBClient.php
<?php
//error_reporting(E_ALL ^ E_DEPRECATED);
class DBClient {
var $host,$db,$user,$pass;
var $mysqli,$isDBConnect;
function __construct() {
    $this->host = "localhost";
    $this->db = "mydb";
    $this->user = "root";
    $this->pass = "pass";
    try {
          $this->mysqli = new mysqli($this->host, $this->user, $this->pass,$this->db );
        if ($this->mysqli->connect_error) {
            die('Error : ('. $this->mysqli->connect_errno .') '. $this->mysqli->connect_error);
        }
    } catch(Exception $ee) {
        $this->link=false;
           $this->isDBConnect=false;
    }
}

public function exeQueryi($query) {
    try {
        $result = $this->mysqli->query($query);
        return $result;
    } catch(Exception $ee) {
        return (FALSE);
    }
}

public function autocommit_false() {
    $this->mysqli->autocommit(FALSE);  
}

public function commit() {
    $this->mysqli->commit();  
}

public function rollback() {
    $this->mysqli->rollback();
}
public function close() {
    $this->mysqli->close();
}
}
?>

MPDF error Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in MPDF57\includes\functions.php

MPDF error Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in MPDF57\includes\functions.php
When you download MPDF from http://www.mpdf1.com/mpdf/index.php  and working on it with latest version of PHP you may encounter following error:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in MPDF57\includes\functions.php on line 99

So How can you solve this problem? follow below steps:

In file "MPDF57/mpdf.php"...........   Line 32140 :  comment listed below line of code:

$temp[2][$iterator] = preg_replace("/^([^\n\t]*?)\t/me","stripslashes('\\1') . str_repeat(' ', ( $tabSpaces - (mb_strlen(stripslashes('\\1')) % $tabSpaces)) )",$temp[2][$iterator]);

TO

//$temp[2][$iterator] = preg_replace("/^([^\n\t]*?)\t/me","stripslashes('\\1') . str_repeat(' ', ( $tabSpaces - (mb_strlen(stripslashes('\\1')) % $tabSpaces)) )",$temp[2][$iterator]);


And also in "MPDF57/includes/function.php"....... Line number: 96 and 97 comment
listed below lines of code:

$str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str);
$str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str);

TO

//$str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str);
//$str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str);


if you are still getting any error then at the top of php page where you are using MPDF use one line of code:

error_reporting(E_ALL ^ E_DEPRECATED);

This will permanently remove the error.

Create a simple page in Laravel using Controller

Create a simple page in Laravel using Controller

1) Create a "ClientpagesController.php" file in "app/controllers/" folder as below contents

<?php
class ClientpagesController extends \BaseController {
  public function contactus(){
     return View::make("contactme");
  }
}

2) Open "app/routes.php" file and paste as:
Route::get("contactus" , "ClientpagesController@contactus");

3) Now create "contactme.php" in "app/views/" folder with any matter,
<html>
...............................
...............................
...............................
</html>

4) Now open this url in browser:
http://localhost:90/MyLaravel/public/contactus

Create a simple page in Laravel using Route

Create a simple page in Laravel using Route

To configure Laravel look here 

Here I am creating a simple "aboutus" page using "Routes" in Laravel.
Follow below steps:

1) Open "app/routes.php" file and paste as:

Route::get('aboutus', function()
{
    return View::make('aboutus');

});

2) Now create "aboutus.php" in "app/views/" folder with any matter,
<html>
...............................
...............................
...............................
</html>

3) now open browser with this URL:
http://localhost:90/MyLaravel/public/aboutus

How to create controller in Laravel

The two methods to create controller in Laravel.
A) By command prompt using "artisan controller:make" :
B) By manually creating controller.
To configure Laravel look here

A) By command prompt using "artisan controller:make" :
I am assuming you are using wamp 2.5.

1- Go to in the "c:\wamp\www\" folder
    Open command window and cd in "c:\wamp\www\"
 
2- type "composer create-project laravel/laravel TestPro1" in command window;
where composer is the exe file name "create-project" is the keywors, "laravel/laravel" is the keyword, "TestPro1" is the project name.
    This will create a folder "TestPro1" with supporting directories and files.
  
3- Rename "server.php" to "index.php"
  
4- Open command prompt in "d:\wamp\www\TestPro1" and type the                                 
"php artisan controller:make MyController".
*Keep in mind that you must in the directory "TestPro1" when you issue the command in command window                            "php artisan controller:make MyController" and there must be a file "artisan", "composer.json", "composer.lock".
    This will create a file "MyController.php" in the "TestPro1\app\controllers".

5- Replace it's index() method as below
    public function index()
        {
             return "This is my web page in Laravel";
        }
    and register it by "Route::resource('welcome','WelcomeController');" in "routes.php" under "D:\wamp\www\TestPro1\app" folder.
    now you can see page content y http://localhost:/TestPro1/

B) By manually creating controller.
Goto "d:\wamp\www\TestPro1\app\controllers" folder. create a file "MyController.php". and paste listed below content.

<?php
class MyController extends \BaseController {

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        //
        return "This is my web page in Laravel";
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store()
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return Response
     */

public function show($id)
    {
        //
    }
    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        //
    }

 /**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function update($id)
    {
        //
    }

 /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        //
    }
}

and register it by "Route::resource('welcome','WelcomeController');" in "routes.php" under "D:\wamp\www\TestPro1\app" folder.
now you can see page content y http://localhost:/TestPro1/

Laravel Installation and configuration

First you need to install Composer from this link:
https://getcomposer.org/download/
Here you can find both installer for windows and Unix.

If you are in windows then download here:  https://getcomposer.org/Composer-Setup.exe
Before installing Composer check that you must have PHP 5.3 or later.

    I am assuming that you are using Wamp 2.5
    - Go to in the "c:\wamp\www\" folder
    - Open command window and cd in "c:\wamp\www\"
    - type "composer create-project laravel/laravel TestPro1" in command window; where composer is the exe file name "create-project" is the keywors, "laravel/laravel" is the keyword, "TestPro1" is the project name.
    - This will create a folder "TestPro1" with supporting directories and files.
    - Rename "server.php" to "index.php"


open browser with this link :
http://localhost/TestPro1/index.php

You can see default page .

How to enable debug on in Laravel

How to enable debug on in Laravel
While working with laravel Framework you could face this error "Whoops, looks like something went wrong."
To overcome this error first you need to see what is the exact error in your code. to show exact error you need to set debug true in "app.php" file.

Follow below steps:

Open "\app\config\app.php" file.
Set " 'debug' => false" to 'debug' => true

Now you can the exact error and fix the error.

Url rewriting in Php

Very simple Url rewriting in Php
Suppose you have a website and you are operating it with query string as below:
http://www.yoursite.com/computer.php?company=asus&name=s56c

you are using two query string "company" and "name". In "company" you are passing "asus" on the other-hand in "name" you are passing "s56c". So the question is that how to convert

"http://www.yoursite.com/computer.php?company=asus&name=s56c"
                                   TO
"http://www.yoursite.com/computer/asus/s56c.html"

The url "http://www.yoursite.com/computer/asus/s56c.html" is not SEO friendly. so how to make it SEO friendly?

It is very simple. for this you need to create ".htaccess" in the root folder where your site's  files existing. paste listed below 3 lines in ".htaccess" file.


Options +FollowSymLinks
RewriteEngine on
RewriteRule computer/(.*)/(.*)\.html computer.php?company=$1&name=$2


And this is the content of your "computer.php" file

<?php
$company=$_GET['company'];
$name=$_GET['name'];
echo $company."--".$name;
?>

open the computer.php as "http://www.yoursite.com/computer/asus/s56c.html"

Access mysql data using mysqli_connect in PHP Class

Access mysql data using mysqli_connect in PHP with mysqli_query

Access mysql record by Object oriented method using class and object in PHP. Here is the class name is "DBClient" and it's method name is "exeQueryi()", that is return record from mysql table name "user_login". The __construct() method automatically called when we create any object of class "DBClient". Here I am using mysqli_connect,mysqli_query,mysqli_num_rows and mysqli_fetch_array.


<?php
class DBClient {
var $host,$db,$user,$pass;
var $linki,$isDBConnect;

function __construct() {
    $this->host = "localhost";
    $this->db = "mydb";
    $this->user = "root";
    $this->pass = "";
    try {
        $this->linki = mysqli_connect($this->host, $this->user, $this->pass,$this->db );
        if (!is_resource($this->linki)) {
            $this->isDBConnect=false;
        } else {
            $this->isDBConnect=true;
        }
    } catch(Exception $ee) {
        $this->linki=false;
           $this->isDBConnect=false;
    }
}

public function exeQueryi($query) {
    try {
        $result = mysqli_query( $this->linki,$query);
        return $result;
    } catch(Exception $ee) {
        return (FALSE);
    }
}
}
?>

<?php
$user_login="admin";
$user_pass="admin";
$sql=sprintf("SELECT *FROM user_info WHERE user_login = '%s' and user_pass='%s'", $user_login,$user_pass);
$db=new DBClient();
$rsLogin=$db->exeQueryi($sql);
$numRows = mysqli_num_rows($rsLogin);
if($numRows>0) {
        $rsLoginRow=mysqli_fetch_array($rsLogin);
        $user_login= $rsLoginRow['user_login'];
        $user_pass=$rsLoginRow['user_pass'];
echo "login found";
} else {
echo "login not found";
}
?>

Show correct date time in PHP

You could be face a accurate Indian date time problem in PHP, because web server located to USA or any other country. that's why date and time which you are looking is wrong. but you can set it. so after set it you can get the correct indian time. you only need to set timezome as listed below:

<?php
date_default_timezone_set('Asia/Calcutta');
?>

Export to excel in PHP

If you have a data and want to generate excel file of that data. then call this listed below function in php.


public function exportToExcelUtil($filename,$data) {
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
echo  $data;
}

Validate email in PHP

Here is the simple php function by this you can validate email which entered by any user.

public function checkEmail($mailID) {
$pat = "/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-.]+\.[a-zA-Z. ]{2,6}$/";
if(preg_match($pat,$mailID)) {
return true;
} else {
return false;
}
}

Access mysql data using Class in PHP


Access mysql data using Class in PHP using mysql_connect and use mysql_select_db and mysql_query


Access mysql record by Object oriented method using class and object in PHP. Here is the class name is "DBClient" and it's method name is "getDistrict", that is show records from mysql table name "district_names". The __construct() method automatically called when we create any object of class "DBClient".


<?php
class DBClient{
var $host;
var $db ;
var $user;
var $pass;
var $link,$isDBConnect;
var $isError,$errorValue;
function __construct() {
$this->host = "localhost";
$this->db = "dbname";
$this->user = "root";
$this->pass = "";
try {
$this->link = mysql_connect($this->host, $this->user, $this->pass);
if (!is_resource($this->link)) {
$this->isDBConnect=false;
}
else {
    mysql_select_db($this->db,$this->link);
$this->isDBConnect=true;
}
}
catch(Exception $ee){
$this->link=false;
   $this->isDBConnect=false;
}
}
public function exeQuery($query) {
try {
$result = mysql_query($query, $this->link);
return $result;
}
catch(Exception $ee){
return (FALSE);
}
}
public function getDistrict() {
 $res=false;
 try {
  $sSql="SELECT * FROM district_names";
  $res=$this->exeQuery($sSql);
  $rows = mysql_num_rows($res);
  if($rows>0) {
  } else {
$res=false;
  }
 } catch(Exception $ee){
  $res=false;
 }
 return $res;
}
}

$dd=new DBClient();
$cntDis=$dd->getDistrict();
if($cntDis) {
while($cntRow=mysql_fetch_array($cntDis)) {
$district_id= $cntRow['district_id'];
$districtname=$cntRow['districtname'];
echo $district_id.'====='.$districtname;
}
 }
?>

Latitude Longitude by address in php

You can find very easily Latitude and Longitude by given address with combination of Google map api and php.
You can easily implement in CodeIgniter,Laravel , CakePHP or any other framewok.

<?php
    $address = 'Sector 37,Noida,India';
    $geocode = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=true');
    $geocode  = json_decode($geocode );
    echo 'Latitude:' . $geocode ->results[0]->geometry->location->lat;
    echo 'Longitude:' . $geocode ->results[0]->geometry->location->lng;

?>

Remove special character in php

You have a website and in that website you have lot of form for user. user fill many data via that forms. some time user feed special characters that are unreadable. so how to remove that special characters before inserting in data base? here is the few lines of code that will do it.

<?php
$input = "Fóø Bår this is the php form data ?A?B?C?D //\\?......!@#$%^&*()_+"; // input text
$output = iconv("utf-8", "ascii//TRANSLIT//IGNORE", $input);
$output =  preg_replace("/^'|[^A-Za-z0-9\s-]|'$/", '', $output); // Remove utf-8 special characters except blank spaces
echo $output; // Results
?>

Cell align top in dataGridView in c#

Use one line code as below:

dataGridView1.Columns["Question"].DefaultCellStyle.Alignment=DataGridViewContentAlignment.TopLeft;

Get Volume Serial Number of Drive in C#

Listed below the code use in your project to get Volume serial number

//let's show C drive's volume serial number
String d = "c";
try {
    System.Management.ManagementObject dsk1 = new System.Management.ManagementObject(@"win32_logicaldisk.deviceid=""" + d + @":""");
    dsk1.Get();
    string s1 = dsk1["VolumeSerialNumber"].ToString();
    MessageBox.Show(s1);
}
catch (Exception ee)
{
    MessageBox.Show(ee.ToString());

}

SEND EMAIL FROM WINFORM

Some times you want to open microsoft outlook from microsoft winform and then type the mail message and send it. use below one line of code.


System.Diagnostics.Process.Start("mailto:XYZ@XYZ.COM");

HOW TO MAKE TRANSPARENT PNG FILE IN C# VB.NET .NET

Problem:

I was working a project where watermark in pdf file as text. but after some time requirement has been changed. the requirement is put watermark as png file in pdf instead of text. The first task was generate transparent png file in C# with given text. the text should be show diagonal. listed below the few lines of code.
HOW TO MAKE TRANSPARENT PNG FILE IN C#





















Solution:

See the below code:

Example:

string text = " this is diognal text for watermark in transparent png file";
Bitmap bmp = new Bitmap(400, 800);
int x = 200, y = 400, angle=55;
Graphics g = Graphics.FromImage(bmp);
System.Drawing.Font f = new System.Drawing.Font("Arial", 25, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
g.Clear(Color.Transparent);
g.TranslateTransform(x, y);
g.RotateTransform(-angle);
g.TranslateTransform(-x, -y);
SizeF size = g.MeasureString(text, f);
g.DrawString(text, f, Brushes.Black, new PointF(x - size.Width / 2.0f, y - size.Height / 2.0f));
bmp.Save("test.png", System.Drawing.Imaging.ImageFormat.Png);
g.Dispose();
 

PDF Water Marker

If you have a PDF with one page or more than one page and want to insert an image as a water mark in that PDF file then you can use this my software. Your are free to use this product.

PDF Water Marker














Before run this application you need to install .Net Framework 4.5

Download PDF Water Marker Here

GET MAC ADDRESS IN C# VB.NET

Problem:

Some time you want to develop a software in C# or Vb.net that will run only on specific computer system. for this you use mac address of that system.

Solution:

Here the C# code that will fetch mac address.

Example:

System.Net.NetworkInformation.NetworkInterface[] nic= System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
String macAddress = string.Empty;
foreach (System.Net.NetworkInformation.NetworkInterface ni in nic)
{
   System.Net.NetworkInformation.IPInterfaceProperties properties=ni.GetIPProperties();
   macAddress = ni.GetPhysicalAddress().ToString();
   if (macAddress != String.Empty) {
                        MessageBox.Show(macAddress);
                        return;
   } 

}



SHOW FORM WITH IN FORM AS IMAGE


Problem:

Some time you have already created many form. then are opening separately when you click on any button in MDI Form or separate in C# winform.  After soe time requirement has changed. the new requirement is to open new form in the same form from where you are clicking button.
For better understand see below image

Show Form with in form as image

















Solution:


Use panel control to show form 


Example:

panel1.Visible = true;
panel1.Controls.Clear();
StandardTest f1 = new StandardTest(); // this the form which you want to show
f1.TopLevel = false;
panel1.Controls.Add(f1);
panel1.Width = 1100;
panel1.Height = 620;
f1.Width = 1100;
f1.Height = panel1.Height - 0;
f1.Dock = DockStyle.Left;
f1.Show();



Adding text in PDF File at specific position Freeware Software

Suppose you have a PDF file; which have one or more than one page and you want to insert text at the specific position. then in this situation you need to use PDF editor and goto each page and put the text at the position where you want. but if the pdf file is having 100 or more pages then it will difficult to edit it. in this condition you can use this my software.

If will make these task very easy, you need to input pdf file, text which you want to see and enter the X and Y position and click Apply button.


Adding text in PDF File at specific position Freeware Software

















It will insert the text at the position which you have supplied in all the pages. To execute this software you need to Microsoft Framework 4.0 or later.

Download Adding text in PDF File at specific position Software





Web page screen capture as image









Web page screen capture as image















Download Web Page Screen Capture as Image









TORCH IN ANDROID



If Torch in your mobile is not existing then download this Android App and you will get torch in your android mobile.


DOWNLOAD TORCH IN ANDROID HERE

reCAPTCHA

Google has improvement it's captcha and introduced new reCAPTCHA


reCAPTCHA 















Follow below steps to implement reCAPTCHA:

1- Sign up google reCAPTCHA site:
http://www.google.com/recaptcha/intro/index.html

2- Register your site domain. after thar it will give you "site key" and "secret key"

ON CLIENT SITE:

1- Paste this line in your web page.
<script src='https://www.google.com/recaptcha/api.js'></script>

2- Paste the <div> tag as same in reCaptcha site:
<div class="g-recaptcha" data-sitekey="YOUR-SITE-KEY"></div> 

ON SERVER SITE:

1-  Send three variable as POST method to url  
https://www.google.com/recaptcha/api/siteverify

Post variable are: secret, response, remoteip
where secret is the your Secret Key
response is recaptcha
remoteip is your remote ip address

//CHECK reCAPTCHA in PHP code
$g_r_r=$POST['g-recaptcha-response'];
if(!empty($g_r_r) && strlen($g_r_r)>0) { 
  $gurl="https://www.google.com/recaptcha/api/siteverify";
  $scrt='YOUR-SECRET KEY';
  $my_ip=$_SERVER['REMOTE_ADDR'];
  $url=$gurl."?secret=".$
scrt."&response=".$g_r_r."&remoteip=".$my_ip;
  
  $c = curl_init();
  curl_setopt($c, CURLOPT_URL, $url);
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($c, CURLOPT_TIMEOUT, 30);
  curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16");

  $c_data = curl_exec($c);
  curl_close($c);
  $res= json_decode($c_data , true);
  if($res['success']>=1) {
    //IMPLEMENT HERE LOGIN LOGIC OR ANY OTHER LOGIC
  }
}