Sunday, January 27, 2013

Turn off resize textarea in Chrome & Safari

There is a new feature in both Safari and Chrome that allows a textarea to be resized by the user. In both browsers the feature is seen by a little icon that is in the bottom right corner of the textarea. This feature gives the user the ability to choose how much space they need for whatever it is they are writing.

The following CSS can be used to remove the users ability to resize the textarea:
1) textarea{resize: none}

Example:
<textarea style="resize: none;" cols="20" rows="2" name="Textarea"></textarea> 

Tuesday, November 20, 2012

Number validation in javascript

javascript code:
<script type="text/javascript">
function number_validation(s)
{
  var i;
  s = s.toString();
  for (i = 0; i < s.length; i++)
  {
     var c = s.charAt(i);
     if (isNaN(c))
       {
        alert("Given value is not a number");
        return false;
       }
  }
  return true;
}
</script>

html code:
<input type="text" name="number" id="number" onkeyup="number_validation(this.value);" />

Sunday, October 21, 2012

how to get real ip in php

function getRealIpAddr()
{
    if (!empty($_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}

Thursday, September 20, 2012

Kitni baatein yaad aati hai...

Kitni baatein yaad aati hai
Tasveerein si ban jaati hain
Main kaise inhein bhooloon
Dil ko kya samjhaun

Kitni baatein kehne ki hai
Honton par jo sehmi si hai
Ik roz inhein sun lo
Kyun aise gum-sum ho

Kyun poori ho na paayi daastaan 

Kaise aayi hai aisi dooriyaan

Dono ke dilon mein chhupa hai
Jo ik anjaana sa gham
Kya ho paayega woh kam
Koyi kya kahe 

Dono ne kabhi zindagi ke
Ik mod pe bhi jo paayi
Hai kaisi woh tanhaai
Koyi kya kahe

Kitna viraan hai ye sama

Saanson mein jaise ghulta hai dhuwaan
Kaisi aayi hai aisi dooriyaan 

Kitni baatein yaad aati hai
Tasveerein si ban jaati hain
Main kaise inhein bhooloon

Sunday, September 16, 2012

How to get backup of database through cron job...

<?php
set_time_limit(3600);//not necessary
backup_tables('localhost','username','pwd','database name');


/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
   
    $link = mysql_connect($host,$user,$pass);
    mysql_select_db($name,$link);
   
    //get all of the tables
    if($tables == '*')
    {
        $tables = array();
        $result = mysql_query('SHOW TABLES');
        while($row = mysql_fetch_row($result))
        {
            $tables[] = $row[0];
        }
    }
    else
    {
        $tables = is_array($tables) ? $tables : explode(',',$tables);
    }
   
    //cycle through
    foreach($tables as $table)
    {
        $result = mysql_query('SELECT * FROM '.$table);
        $num_fields = mysql_num_fields($result);
       
        $return.= 'DROP TABLE '.$table.';';
        $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
        $return.= "\n\n".$row2[1].";\n\n";
       
        for ($i = 0; $i < $num_fields; $i++)
        {
            while($row = mysql_fetch_row($result))
            {
                $return.= 'INSERT INTO '.$table.' VALUES(';
                for($j=0; $j<$num_fields; $j++)
                {
                    $row[$j] = addslashes($row[$j]);
                    $row[$j] = ereg_replace("\n","\\n",$row[$j]);
                    if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
                    if ($j<($num_fields-1)) { $return.= ','; }
                }
                $return.= ");\n";
            }
        }
        $return.="\n\n\n";
    }
    //save file
    $handle = fopen('dbbackup\db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+');
    fwrite($handle,$return);
    fclose($handle);
}
?>

Friday, September 14, 2012

Chot Pe Chot

this is a real story based on 'Shimla trip-delhi to shimla' of three friends...
       in this story, there were three gud frnds i mean still they are gud frnds name MJ, Jais and kabeer. sometimes we feel that in our city nobody can cheat you. but in this story you will come to know that any body can make you 'Topa'.

      so guys without wasting your time and i think ki ab is story ki bhoomika bhi bahut ban gayi ab story start karta hu. hamara delhi se kalka ka reservation train no 12311 hwh dli klk mail se tha, waise mujhe is tarin ka no abhi tak sirf isliye yad hai just bcoz ye train no thoda easy lagta hai. well trip pe jane wale din se approx one week pahle se hi MJ ne train ki history and timing pe paini (tez) najre rakhi aur ye observe kiya ki train almost time pe hi rahti hai bt as we all know ki story ka name 'chot pe chot ' hai so train to late honi hi thi.