Grab the RSS feed

Convert the time zone in PHP

In my application the client want to display the timezone in PST.
But default the time is displayed in MST.That is we get the time from server and displayed in aparticular page.
But the client want to show only in the particular page in PST.So I get the Program from PHP http://www.php.net/manual/en/function.date.php and use it.

Here I need to change the America/New_York to America/Los_Angels and it display the PST time

If you want it to display in different format change the argument in $format.Instead of g:i A T use D,h A T etc.
#

< ?php
function date_at_timezone($format, $locale, $timestamp=null){

if(is_null($timestamp)) $timestamp = time();

//Prepare to calculate the time zone offset
$current = time();

//Switch to new time zone locale
$tz = date_default_timezone_get();
date_default_timezone_set($locale);

//Calculate the offset
$offset = time() - $current;

//Get the date in the new locale
$output = date($format, $timestamp - $offset);

//Restore the previous time zone
date_default_timezone_set($tz);

return $output;

}

//Examples
$t = time();

print date("g:i A T", $t); //4:16 PM PDT
print date_at_timezone("g:i A T", "America/New_York", $t); //7:16 PM EDT
print date_at_timezone("g:i A T", "Pacific/Samoa", $t); //12:16 PM SST
print date("g:i A T", $t); //4:16 PM PDT
? > 

Leave the comments to improve us….
Click Here to download as word document...

Expand the tree without Disclosure Icon and change the tree Icons

Today I face the problem of open the tree without using the disclosure open and Close Icon and also they need to changr the First folder Icon only.

Then I need to make the search and find out code for open the tree without disclosure Icon and also I merged the code for change the tree’s first folder.

I give the coding below…

You can use it.
Thanks for flexexamples

< ?xml version="1.0" encoding="utf-8"?> 
< !-- http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/ --> 
< mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"> 

< mx:Script> 
< ![CDATA[
import mx.collections.ICollectionView;
import mx.events.ListEvent;

< !----- Function to change the folder Icon of first node ----!> 
[Embed("assets/folder_table.png")]
private var FolderTableIcon:Class;

private function init():void 
{
var nodeOne:XML = xmlListColl.getItemAt(0) as XML;
tree.setItemIcon(nodeOne, FolderTableIcon, FolderTableIcon);

}
< !---Function for open the tree without disclosure Icon ---!> 
private function tree_itemClick(evt:ListEvent):void {
var item:Object = Tree(evt.currentTarget).selectedItem;
if (tree.dataDescriptor.isBranch(item)) {
tree.expandItem(item, !tree.isItemOpen(item), true);
}
}

private function tree_labelFunc(item:XML):String {
var children:ICollectionView;
var suffix:String = "";
if (tree.dataDescriptor.isBranch(item)) {
children = tree.dataDescriptor.getChildren(item);
suffix = " (" + children.length + ")";
}
return item[tree.labelField] + suffix;
}
]]> 
< /mx:Script> 

< mx:XML id="dp"> 
< root> 
< folder label="One"> 
< folder label="One.A"> 
< item label="One.A.1" /> 
< item label="One.A.2" /> 
< item label="One.A.3" /> 
< item label="One.A.4" /> 
< item label="One.A.5" /> 
< /folder> 
< item label="One.1" /> 
< item label="One.2" /> 
< /folder> 
< folder label="Two"> 
< item label="Two.1" /> 
< folder label="Two.A"> 
< item label="Two.A.1" /> 
< item label="Two.A.2" /> 
< /folder> 
< /folder> 
< /root> 
< /mx:XML> 

< mx:Tree id="tree"
dataProvider="{dp}"
showRoot="false"
labelField="@label"
labelFunction="tree_labelFunc"
width="300"
rowCount="6"
itemClick="tree_itemClick(event);" /> 

< /mx:Application> 


You can also download this coding from click here

Leave the comments to Improve us….

Happy X mas

Hello friends,

Happy Christmas.And also I wish you the happy nw yaer.....

This new year will bring you to the happiest moment .......

Set maxLength Using Javascript

Hello friends,

Sometimes we need to set the maxlength for textbox or textarea depend upon the value selected.
For example if you select the country then we need to set the zip code length depend upon the country.
If the country selection is depend upon the ajax it is easy to set the length.

For example in US the zip code contain only 5 characters.But in india this going to be six.
It is simple and easiest way in the javascript.Set the maximum length by using the following code...

  
document.getelementid('textbox1").maxLength=10

Click Here to download as PDF format..

Leave the comment to improve us...

TechnoRati

This is a post for Technorati verification TW7YARVHC2ZT

Page redirection Using PHP

The simplest and easiest way is header redirection in PHP.

The Header redirection has the PHP following syntax.

void header ( string $string [, bool $replace = true [, int $http_response_code ]] )

Whenever you need to redirect the page you can use this.

Today I need to solve the issue that contains this problem.

My situation is when the user get the Message it will open in the Jquery Modal box with the button read and delete. When they get the popup and click the button it will redirect to the page with the url of ?MessageID=’something.’

Even if delete the message it will called in the ajax and the URL is NOT cleaned .Then after delete the ID also going to be cleared in Database. IF the user going to refresh after delete the message it gives the SQL error because of there is no such a ID.

In that situation I use the above header redirection. That is I check whether the ID is NULL. If it is NULL then I redirect to the another URL.

Otherwise I can do the Operation as Read a Message.


Leave the comments to improve ourself………….

For more Information visit this site

Click Here to download as a PDF format

Concatenation in PHP

The easiest one operation in PHP is the concatenation operation.

This is need only one dot operator for the concatenation .Whenever we need the concatenation it tooks the simple dot and append the variable we need.

The below code simply illustrates the two methods of Concatenation.

< !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 > concatenation< /title > 
< /head > 

< body > 
< ?
$var1=' I am';
$var2=' a';
$var3=' boy';
echo $var1.$var2.$var3;
echo "< br/ > ";
/************otherwise we can use like the below operation**************/
$var4=' Hello ';
$var4.='world';
echo $var4;

? > 
< /body > 
< /html > 



Leave the comments to improve ourself…..

Click Here to download as PDF Format

Connect to database using PHP

Connecting to the data base is the very effective and really needed one. Whenever you going to perform the signup or other activities we need to update or insert the user activity to the databse.

So the database connection playing vital role in website operations.

So we need to connect our database for perform operation by using following code.

It is really simple to connect the database,

< ?php

$con = mysql_connect("localhost","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database_name ", $con);

? >

Put your password and database_ name to connect ..

Leave the comments….It will help us to improve

Click Here to download this article as PDF format

Page Redirection Using Jquery

Sometimes we need to redirect the page from the current page to another page.For example if the login is successful the we need to redirect into the Myprofile page or another page wherever you want.

This is simple in Jquery.

Like the javascript window.location.href here also we have the function to redirect.

In the below example I illustrate the page redirection with simple button.If you want to make it depend upon user input in textbox there is also a code.For that you can simply remove the comment lines and use it.

The code is given below

< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< xmlns="http://www.w3.org/1999/xhtml">
<>
< equiv="Content-Type" content="text/html; charset=utf-8">
<>
< src="jquery/jquery.js" type="text/javascript">< /script >
<>
$(document).ready(function(){
$("#pageredirect").click(function()
{
/*Remove the comment line and put the comment line in var url="http://www.technotiger87.blogspot.com";*/
/*It will redirect to the particular page given by user in text box*/
//var url=$("#testing").val();

var url = "http://www.technotiger87.blogspot.com"; 
$(location).attr('href',url);

});
});
< /script >
< /head >
<>
< !--Remove the below comment line when you want to enter the URL and redirect it-- >
< !--Redirect Url:< type="text" name="testing" id="testing">
< type="button" name="pageredirect" id="pageredirect" value="Redirect">
< /body >
< /html >

click here to download at pdf format

Leave the comments…

Decrypt MD5 using the following code in PHP

Most of us are known about encryption and decryption. Even though we known I give the small introduction about the encryption.

Encryption is used to provide the security to the user. In this way we convert one type of text into another and those who are doesn’t know the decryption they doesn’t read the encryption text.

The encryption is started in the old days. Not find out after the technical era.

In this way we can say MD5 is the one way encryption and oesnt decrypt it.

But the below code provide you to read the encrypted text. But it is available only when small amount of text.

If you find complex words please inform me to improve my knowledge.

The code is shown below.

< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< xmlns="http://www.w3.org/1999/xhtml">
<>
< equiv="Content-Type" content="text/html; charset=utf-8">
<> MD5Decryption< /title >
< /head >

<>
< ?
$hash = "202cb962ac59075b964b07152d234b70";
$char[1] = "a";
$char[2] = "b";
$char[3] = "c";
$char[4] = "d";
$char[5] = "e";
$char[6] = "f";
$char[7] = "g";
$char[8] = "h";
$char[9] = "I";
$char[10] = "j";
$char[11] = "k";
$char[12] = "l";
$char[13] = "m";
$char[14] = "and";
$char[15] = "o";
$char[16] = "p";
$char[17] = "q";
$char[18] = "are";
$char[19] = "s";
$char[20] = "t";
$char[21] = "you";
$char[22] = "v";
$char[23] = "w";
$char[24] = "x";
$char[25] = "y";
$char[26] = "z";
$char[27] = "0";
$char[28] = "1";
$char[29] = "2";
$char[30] = "3";
$char[31] = "4";
$char[32] = "5";
$char[33] = "6";
$char[34] = "7";
$char[35] = "8";
$char[36] = "9";
$char[37] = "A";
$char[38] = "B";
$char[39] = "C";
$char[40] = "D";
$char[41] = "E";
$char[42] = "F";
$char[43] = "G";
$char[44] = "H";
$char[45] = "I";
$char[46] = "J";
$char[47] = "K";
$char[48] = "L";
$char[49] = "M";
$char[50] = "and";
$char[51] = "O";
$char[52] = "P";
$char[53] = "Q";
$char[54] = "are";
$char[55] = "S";
$char[56] = "T";
$char[57] = "you";
$char[58] = "V";
$char[59] = "W";
$char[60] = "X";
$char[61] = "Y";
$char[62] = "Z";
$top = count($char);
For ($d = 0; $d < = $top; $d++)
{
$ad = $ae.$char[$d];
for ($c = 0; $c < = $top; $c++)
{
$ac = $ad.$char[$c];
for ($b = 0; $b < = $top; $b++)
{
$ab = $ac.$char[$b];
for ($a = 0; $a < = $top; $a++)
{
$aa = $ab.$char[$a];
if(md5($aa)==$hash)
{
die('Wachtwoord: '.$aa);
}
}
}
}
}
Echo "Geen Result.";

? >
< /body >
< /html >


Please leave the comments…


Click to Download in the word format

Set the session Using Jquery

Sessions are playing vital role in the web development. Most of the time we need to set the session during development.

For example when the user get the successful login we set the session Id or Cookie to track the user for the full of successful session.

If we develop the code using Jquery we can create the session using Jqury session plugin.

For that plugin you can download it from the following link

http://code.google.com/p/jquery-session/downloads/list

I used the version 0.3 in this example

In this version there is also a JQuery, Json .Jquery.session is available.You can use it depend upon your meeds.

The following PHP program set the session using Jquery

< !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 > Seesion Using Jquery< /title > 
< script type="text/javascript" src="jquery/jquery.js" > < /script > 
< script type="text/javascript"  src="jquery/jquery.session.js" > < /script > 
< script type="text/javascript" > 
$(document).ready(function(){
$.session("example","mysession");
alert($.session("example"));
});
< /script > 
< /head > 

< body > 
< !--Please Visit http://technotiger87.blogspot.com and leave the comments-- > 
< /body > 
< /html > 

Use this and leave the comments

How to disable the outgoing calls eventhough there is balance

Whenever you going to give the mobile to your or well known person you get doubt whether they can make a call.

Sometimes you cant told about don’t make a call. Because it may totally broke the relationship.

At that time you have simply change your settings and give the mobile. The settings we made doesn’t make any outgoing call. What do you change your setting?

In Nokia go to settings and then choose call settings and then go to send my caller identity and choose No in the send my caller identity.

Now make the call .The outgoing doesn’t enabled. And you can save the money and friendship.


When you make the call it tolds only the network failure.

Please leave comments

Text box allow only the numbers by using Jquery

Today I need a coding for text box only allow the numbers. I got the script from the net. Here I am going to present for www.scribd.com users.

The coding shows below…


HTML coding..

<!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/jquery.js"></script>
< script type="text/javascript" src="jquery/jqueryvalid.js"></script>
</head>
< body>
< input type="text" name="quantity" id="quantity" /> 
</body>
</html>


Before going to run the code please note I include the jquery.js. This is the file you can get from http://jquery.com/ .before the jquery/jquery.js here jqurey is the folder name you can write as username/jquery.js or else what you wish..

Then in next I include another javascript file named jqueryvalid.js.Here you need to write the jqueryvalid.js in the jquery folder.

jqueryvalid.js ……
$(document).ready(function(){

$("#quantity").keypress(function (e){
if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
{
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow"); 
return false;
} 

});

});


Whenever the key pressed within the textbox it is checked ASCII character for whwther is it number or alphabet. If alphabet it wont be allowed to enter.

It is really useful for validation…

Hide a Table Column Using Jquery

Today I need a coding for hide table column in a table. Here I am going to present for our blog users.

The coding shows below…


HTML coding..

<!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/jquery.js"></script>
< script type="text/javascript" src="jquery/hidetable.js"></script>

</head>

< body>
< table>
< tr>
< td>
< input type="radio" id="radiobtn" name="radiobtn" value="1"/ > Show Table column<br/>
< input type="radio" id="radiobtn" name="radiobtn" value="2"/ > Show Table column<br/>
< input type="radio" id="radiobtn" name="radiobtn" value="3"/ > Hide Table Column<br/>
</td>
< td id="hidecolumn">
< input type="checkbox" name="checkme" id="checkme"/> Check me
< input type="text" name="entertext" id="entertext"/> I am Text box
</td>
< tr>
</table>
</body>
</html>


Before going to run the code please note I include the jquery.js. This is the file you can get from http://jquery.com/ .before the jquery/jquery.js here jqurey is the folder name you can write as username/jquery.js or else what you wish..

Then in next I include another javascript file named jqueryvalid.js.Here you need to write the jqueryvalid.js in the jquery folder.

jqueryvalid.js ……

$(document).ready(function(){
$("input:radio[name='radiobtn']").click(function() {
var isDisabled = $(this).is(":checked") && $(this).val() == "3";
if(isDisabled==true)
{
$("#hidecolumn").hide();

}
else
{
$("#hidecolumn").show();

}
});

});

Use this and leave the comment.

Get the dropdown value using Jquery

Today I am going to tell you how to get the dropdown value when the user clicks on it. It sometimes very much useful to get the value and stored it on database.

For example you may use the time zone or anything.At that time it provides more helpful to you.

Even this is going to be small thing it helps a lot.

Here the HTML code is displayed…

;">< !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/jquery.js" > < /script > 
< script type="text/javascript" src="jquery/getdropdownvalue.js" > < /script > 
< /head > 

< body > 
< select name="getdropdown" id="getdropdown" > 
< option value="1" > Trial  1< /option > 
< option value="2" > Trial  2< /option > 
< option value="2" > Trial  3< /option > 
< option value="2" > Trial  4< /option > 
< option value="2" > Trial  5< /option > 
< option value="2" > Trial  6< /option > 
< /select > 
< /body > 
< /html > 

The Jquery will be coded below as…
$(document).ready(function(){

$("#getdropdown").change(function() {
var trial=$("#getdropdown option:selected").text();
alert(trial);
});

});


Here getdropdown is the ID of dropdown box

You can put val() instead of text() you get the dropdown value

Create a cookie using Jquery

Today I told you the fact creating cookie.Creating cookie is often we need when we develop the site.

Here I told you how to create a cookie .

Creating a cookie in Jquery is very simple than other languages.But for creating a cookie you need the plugin you can download it from the following link.

http://plugins.jquery.com/files/jquery.cookie.js.txt

< !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/jquery.js" > < /script > 
< script type="text/javascript" src="jquery/cookie.js" > < /script > 
< script type="text/javascript" > 
$(document).ready(function(){
$.cookie("example","mycookie");
});
< /script > 
< /head > 

< body > 
< ?php echo $_COOKIE["example"];? > 
< /body > 
< /html > 



Run the above code will give result of cookie value. The
$.cookie("example","mycookie");
means example give name to cookie,mycookie is the value

My cookie is printed on the page.

You can delete the cookie by
$.cookie("example", null);
Create the cookie with expiration

$.cookie("example", "foo", { expires: 7 });
Please leave the comments

Click on the text for select the radio button

Some times we need to make the radio button going to be selected whenever the text near to the radio button is clicked.

For this kind of program we doesn’t need any javascript or anything. Even we doesn’t need the form.

The following example shows that method.

Use this code and leave the comments

< !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 > 
< /head > 

< body > 
< p > Try clicking on the text labels:< /p > 
< input type="radio" name="sex" id="male" / >   
< label for="male" > Male< /label > 
< br / > 
< input type="radio" name="sex" id="female" / >   
< label for="female" > Female< /label > 
< /body > 
< /html > 


Note the above code name contain the same name for both label.But the id contain different name.So using that we can perform the function.

Use it and leave the comments to improve …

Avoid the errors in the PHP

Sometimes we need to avoid the warnings in the PHP. We know very well these warnings doesn’t need to take care. These kind of we need to use one PHP function.

It doesn’t display any Errors on the page. Be careful to using this kind of function.

The below example illustrate how to avoid errors,

Include the below lines into the Container file where the error coming from

php ini_set('display_errors',0)


When using this the errors doesn’t display on the page.

URL Rewriting

Sometimes you may be seen the URL doesn’t have the extensions like .php, .html, .asp or anything else.
Because they are aware of SEO and the security .Before going to the URL rewrite we see the small introduction of SEO.

What is SEO?

1. SEO stands for Search Engine Optimization.
2. If you don’t know about SEO what do you first do?
3. Go for the Google or other search engines then type SEO and press enter. It provides the millions and millions of WebPages
4. But you read only the first few pages or first page alone.
5. So the website owners work hard to publish their pages in the first few pages.
6. What are the advantages for them?
7. They got advertising through the page rank. So they earn the lot.
8. For this purpose we go for the url rewriting.

URL rewriting in PHP

For this you need to run in the linux server.

Step 1:Create the file using notepad or wordpad with extension “.htaccess”.It must be accurate.
Step 2:save in the root directory.
Step 3:create the PHP file

< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< xmlns="http://www.w3.org/1999/xhtml">
<>
< equiv="Content-Type" content="text/html; charset=utf-8">
<> Trial< /title >
< ?php
$_GET;
? >
< /head >

<>

<> <>
< href="Ajaxhelper"> Test This < /a > <> <>
< href="PHP">  I am going to test < /a > <> <>
< href="Ajax"> Then  < /a > <> <>
< href="Java1234">  Watch  < /a > <> <>
< href="pg123">  The< /a > <> <>
< href="1234">   URL < /a >
< /body >
< /html > 

Then Create the .htaccess file

Options +FollowSymlinks
RewriteEngine On
# Prevent Directory Listing
Options -Indexes
RewriteRule ^([a-z0-9A-Z]+)/?$ index.php?a=$1 [QSA]


How it runs?
• RewriteRule - Tells Apache that this like refers to a single RewriteRule.
• RewriteEngine On- # Turn on the rewriting engine
• # - Command Line
• Options +FollowSymlinks – It is an optional


Don’t forget to put $_GET on the PHP file.If you don’t put it it wont be run. Please try it and leave comments…

Declare the variable globally in Java script

Today I am facing the problem of get the value from the variable that declared inside the function. But I need to get that value from outside of the function.

For that we need th declare the variable globally is the best way of doing program.

In Java script it is simple technique to globally declare the variable.

How can you declare the variable globally?

Is we need to put global infront of that.No…

See the following program…..

Function1()

{

Var myname;//declared globally

Function2()

{

Var myaddress;//with in the function

Myname//access in this function

}

Function3()

{

Myname;

}

}

When accessing the global variable don’t put var within the function…

Read and use it.Leave the comments for improvements…

 
Real Time Web Analytics