Posts Tagged ‘PHP’

The 10 most important skills for future programmers

Sunday, September 6th, 2009

It is important to ensure that we are benefiting as much as possible when we invest time and effort to train and learn new things.

The following list will see the 10 we should learn skills that our curriculum is relevant for the next 5 years. This list is not complete and covers some niche markets (such as mainframes). However, if you learn at least seven items in this list you will not miss it.

1. One of the “Big 3″ (Java, . NET & PHP)

Barring a radical change in the world of development (such as an asteroid falling on Redmond), most developers will need to know any of the three major systems development: Java,. NET (VB.NET or C #) or PHP. Nor enough to know the main language. As projects grow and are grabbing more functionality, we will need to know the frameworks and libraries associated with depth.

2. Rich Internet Applications (RIA – Rich Internet Applications)

They can love or hate, but in recent years, Flash is being used for something other than funny animations. Flash also gained additional functionality in the form of Flex and AIR. Competitors of Flash, as JavaFX and Silverlight are also improving in performance. The browsers are improving their JavaScript engine, which is emerging as a web application platform. To make things more complicated, HTML 5 is going to incorporate lots of RIA functionality, including connection to the database, thus the formal seal of the W3C to AJAX. In the near future, have experience of RIA will be a determining factor in our curriculum.

3. Web Development

Web development will not disappear in the future. Many developers were happy so far ignored the web, or just staying with “the basics” that gave them their framework. But companies are demanding more and more to those who really know how to work with the underlying technologies. So we should improve our knowledge of JavaScript, CSS and HTML to succeed in the next five years.

4. Web Services

“REST or SOAP? JSON or XML? Although the election and the answers depend on the project, it is increasingly difficult to be a developer without having to consume Web Services (even if our development is not a Web application). Even the land area used to be ODBC, COM or RPC are now moving to Web services of some kind. Developers who can not work with Web services will end up relegated to maintenance on legacy code.

5. Human skills

There is a trend that has occurred some time ago: the increasing visibility of IT within and outside the organization. The developers are taking more and more meetings that are not development and process for obtaining feedback from them. For example, the CFO can not change the accounting rules without working with IT to update the system. And an operations manager can not change the process of call without IT center update the CRM work-flow. Similarly, customers often need to work directly with development teams to ensure their needs are met. Will it be necessary for all developers to consider how to win friends and influence people? No. But the developers that they will do will be much more valuable to their employers – and are highly sought after in the market.

6. A dynamic programming language and / or functional

Languages like Ruby, Python, F # and Groovy are not yet very popular – but so are the ideas behind them. For example, the LINQ system. NET is a direct descendant of functional programming techniques. Both Ruby and Python are becoming increasingly popular in some quarters, thanks to the Rails framework and Silverlight respectively. Learn one of these languages will not only improve our curriculum, but also will expand our horizon. All great developers recommend learning at least one dynamic or functional languages to make learning new ways of thinking.

7. Agile Methodologies

As time passes, the ideas behind Agile become more defined and better expressed. Many organizations are adopting Agile or proofs of concept for doing Agile. Although Agile is no silver bullet to avoid failure in a project definitely has its place in many projects. Developers who have experience in working and understanding Agile environments will be increasingly in demand in the next five years.

8. Domain Knowledge

Hand in hand with the agile methodologies, development teams are increasingly viewed partners in the project definition. This means that developers who understand the problem domain will be able to contribute to the project in a very visible and valuable. With Agile, a developer can say “From here, we can very easily add this functionality, and you get great value,” or “Hey, this requirement is not in keeping with the pattern of use that the logs show. No matter how many developers resist the idea of knowing anything about the problem domain, it is undeniable that more and more organizations prefer (if not even require) developers to at least understand the basics of the business.

9. “Hygiene” development

Until a few years ago, many (if not all) organizations had no access to bug tracking systems, version control and other tools, all developers are summarized and their preferred IDE. But thanks to the creation of new integrated development environments and the explosion of free software environments of high quality, since there are almost no organizations without these tools. Developers have to know much more than just do a checkout of the code. You need to have a rigorous hygiene habits to ensure they are properly coordinated with the team. The “solitary programmers” that keep everything local, non-document changes and others will not be welcome in traditional organizations, and will be aa directly out of place in Agile environments, where you use a strong coordination between equipment to operate.

10. Mobile Development

During the late 1990 web development grew and gained widespread adoption, so begin to displace traditional desktop applications. In 2008, development for mobile devices eventually took off, and over the next five years will grow steadily. Of course, there are several approaches to mobile development: web applications designed to run on mobile devices, RIAs aimed at this market, and applications that run directly on the devices. No matter what path we choose, we will serve add mobile development skills to our group.

PHP on Windows Training Kit (April 2009)

Wednesday, May 13th, 2009

Now Microsoft has published Training toolkit ie. PHP On Windows Training Kit (April 2009). This is a kit designed to help PHP developers can build applications in this language and platform for Windows and using IIS 7 and SQL Server 2008. The kit includes the following elements:

* PHP & SQL Server Demos.
* Integrating Geo-Spatial SQL Server with PHP.
* SQL Server Reporting Services and PHP.
* PHP & SQL Server Hands On Labs
* Introduction to Using SQL Server with PHP
* Full Text Search Using Office Documents in PHP over.
* PHP on Windows Hands On Labs
* IIS Access Control Features for PHP.
* Media Features Using IIS 7.0 in a PHP Application.
* Troubleshooting PHP.
* Migrating PHP Applications to IIS 7.0.

Link: Via Microsoft

Validate: Username, Email Id, Phone No, Zip Code & URL In 5 Languages(JS, C#.Net, VB.Net, JAVA & PHP)

Monday, March 23rd, 2009

Validate of Username, Email Id, Phone No, Zip/Postal Code & URL In Javascript, C#.Net, VB.Net, JAVA & PHP !

1. Validate username: Validate alpha numeric values
2. Validate email addresses : example@domain.com
3. Validate Phone numbers: Validate US phone number eg: 123-456-7890
4. Validate Zip/Postal Codes: Validate US Zip/Postal Code eg: 12345-6789
5. Validate Domain Name eg: http://live.com

Validate username: Validate alpha numeric values

?View Code JAVASCRIPT
function is_valid_username(str_username)
{
 var filter = /^([a-zA-Z\s0-9]*)$/;
 if (!filter.test(str_username))
 {
 alert(’Wrong username format.’);
 }
 else
 {
 alert('Username format is ok.')
 }
 return false;
}
?View Code CSHARP
 using System.Text.RegularExpressions;
 
 private void is_valid_username(string str_username)
 {
 Regex matchRegex = new Regex(@"^[a-zA-Z0-9_]{3,16}$");
 MatchCollection matches  = matchRegex.Matches(str_username);
 if(matches.Count==0)
 {
 Response.Write("Wrong username format."); // In Webserver
 //MessageBox.Show("Wrong username format."); //In Windows Form
 }
 else
 {
 Response.Write("Username format is ok."); // In Webserver
 //MessageBox.Show("Username format is ok."); //In Windows Form
 }
 }
Imports System.Text.RegularExpressions
 
Private Sub is_valid_username(ByVal str_username As String)
    Dim matchRegex As New Regex("^[a-zA-Z0-9_]{3,16}$")
    Dim matches As MatchCollection = matchRegex.Matches(str_username)
    If matches.Count = 0 Then
        Response.Write("Wrong username format.") ' In Webserver
        'MessageBox.Show("Wrong username format."); 'In Windows Form
    Else
        Response.Write("Username format is ok.")    ' In Webserver
        'MessageBox.Show("Username format is ok."); 'In Windows Form
    End If
End Sub
import java.util.regex.*;
 
public class is_valid_username
{
 public static void main(String str_username)
 {
 Pattern p=Pattern.compile("^[A-Za-z0-9]+$");
 Matcher m=p.matcher(str_username);
 boolean matchFound = m.matches();
 if(matchFound)
 {
 System.out.println("Username format is ok.");
 }
 else
 {
 System.out.println("Wrong username format.");
 }
 }
}
Function is_valid_username($str_username)
{
 if (preg_match('/^[a-z\d_]{5,20}$/i',$str_username))
 {
     echo "Username format is ok.";
 }
 else
 {
     echo "Wrong username format.";
 }
}

Validate email addresses : example@domain.com

?View Code JAVASCRIPT
function is_valid_email(str_email_id)
{
 var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
 if (!filter.test(str_email_id))
 {
 alert(’Wrong email address format.’);
 }
 else
 {
 alert('Email address format is ok.')
 }
 return false;
}
?View Code CSHARP
 using System.Text.RegularExpressions;
 private void is_valid_email(string email_id)
 {
 Regex matchRegex = new Regex(@"[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5}");
 MatchCollection matches  = matchRegex.Matches(email_id);
 if(matches.Count==0)
 {
 Response.Write("Wrong email address format."); // In Webserver
 //MessageBox.Show("Wrong email address format."); //In Windows Form
 }
 else
 {
 Response.Write("Email address format is ok."); // In Webserver
 //MessageBox.Show("Email address format is ok."); //In Windows Form
 }
 }
Imports System.Text.RegularExpressions
 
Private Sub is_valid_email(ByVal email_id As String)
    Dim matchRegex As New Regex("[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]{2,5}")
    Dim matches As MatchCollection = matchRegex.Matches(email_id)
    If matches.Count = 0 Then
        Response.Write("Wrong email address format.") ' In Webserver
        'MessageBox.Show("Wrong email address format."); 'In Windows Form
    Else
        Response.Write("Email address format is ok.")    ' In Webserver
        'MessageBox.Show("Email address format is ok."); 'In Windows Form
    End If
End Sub
import java.util.regex.*;
public class is_valid_email
{
 public static void main(String str_email_id)
 {
 Pattern p=Pattern.compile("[a-zA-Z]*[0-9]*@[a-zA-Z]*.[a-zA-Z]*");
 Matcher m=p.matcher(str_email_id);
 boolean matchFound = m.matches();
 if(matchFound)
 {
 System.out.println("Email address format is ok.");
 }
 else
 {
 System.out.println("Wrong email address format.");
 }
 }
}
Function is_valid_email($email_id)
{
 if (preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$email_id))
 {
     echo "Email address format is ok.";
 }
 else
 {
     echo "Wrong email address format.";
 }
}

Validate Phone numbers: Validate US phone number eg: 123-456-7890

?View Code JAVASCRIPT
function is_valid_phone_no(str_phone_no)
{
 var filter =  /^((\+?1-)?\d\d\d-)?\d\d\d-\d\d\d\d$/;
 if (!filter.test(str_phone_no))
 {
 alert(’Wrong phone number format.’);
 }
 else
 {
 alert('Phone number format is ok.')
 }
 return false;
}
?View Code CSHARP
 using System.Text.RegularExpressions;
 
 private void is_valid_phone_no(string str_phone_no)
 {
 Regex matchRegex = new Regex(@"\d{3}-\d{3}-\d{4}$");
 MatchCollection matches  = matchRegex.Matches(str_phone_no);
 if(matches.Count==0)
 {
 Response.Write("Wrong phone number format."); // In Webserver
 //MessageBox.Show("Wrong phone number format."); //In Windows Form
 }
 else
 {
 Response.Write("Phone number format is ok."); // In Webserver
 //MessageBox.Show("Phone number format is ok."); //In Windows Form
 }
 }
Imports System.Text.RegularExpressions
Private Sub is_valid_phone_no(ByVal str_phone_no As String)
    Dim matchRegex As New Regex("\d{3}-\d{3}-\d{4}$")
    Dim matches As MatchCollection = matchRegex.Matches(str_phone_no)
    If matches.Count = 0 Then
        Response.Write("Wrong phone number format.") ' In Webserver
        'MessageBox.Show("Wrong phone number format."); 'In Windows Form
    Else
        Response.Write("Phone number format is ok.")    ' In Webserver
        'MessageBox.Show("Phone number format is ok."); 'In Windows Form
    End If
End Sub
import java.util.regex.*;
public class is_valid_phone_no
{
 public static void main(String str_phone_no)
 {
 Pattern p=Pattern.compile("^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$");
 Matcher m=p.matcher(str_phone_no);
 boolean matchFound = m.matches();
 if(matchFound)
 {
 System.out.println("Phone number format is ok.");
 }
 else
 {
 System.out.println("Wrong phone number format.");
 }
 }
}
Function is_valid_phone_no($str_phone_no)
{
 if (preg_match('/\(?\d{3}\)?[-\s.]?\d{3}[-\s.]\d{4}/x',$str_phone_no))
 {
     echo "Phone number format is ok.";
 }
 else
 {
     echo "Wrong phone number format.";
 }
}

Validate Zip/Postal Codes: Validate US Zip/Postal Code eg: 12345-6789

?View Code JAVASCRIPT
function is_valid_zip_code(str_zip_code)
{
 var filter =  /^\d\d\d\d\d-\d\d\d\d$/;
 if (!filter.test(str_zip_code))
 {
 alert(’Wrong Zip/Postal Code format.’);
 }
 else
 {
 alert('Zip/Postal Code format is ok.')
 }
 return false;
}
?View Code CSHARP
 using System.Text.RegularExpressions;
 
 private void is_valid_zip_code(string str_zip_code)
 {
 Regex matchRegex = new Regex(@"\d{5}-\d{4}$");
 MatchCollection matches  = matchRegex.Matches(str_zip_code);
 if(matches.Count==0)
 {
 Response.Write("Wrong Zip/Postal Code format."); // In Webserver
 //MessageBox.Show("Wrong Zip/Postal Code format."); //In Windows Form
 }
 else
 {
 Response.Write("Zip/Postal Code format is ok."); // In Webserver
 //MessageBox.Show("Zip/Postal Code format is ok."); //In Windows Form
 }
 }
Imports System.Text.RegularExpressions
Private Sub is_valid_zip_code(ByVal str_zip_code As String)
    Dim matchRegex As New Regex("\d{5}-\d{4}$")
    Dim matches As MatchCollection = matchRegex.Matches(str_zip_code)
    If matches.Count = 0 Then
        Response.Write("Wrong Zip/Postal Code format.") ' In Webserver
        'MessageBox.Show("Wrong Zip/Postal Code format."); 'In Windows Form
    Else
        Response.Write("Zip/Postal Code format is ok.")    ' In Webserver
        'MessageBox.Show("Zip/Postal Code format is ok."); 'In Windows Form
    End If
End Sub
import java.util.regex.*;
public class is_valid_zip_code
{
 public static void main(String str_zip_code)
 {
 Pattern p=Pattern.compile("^(\\d{5})[- ]?(\\d{4})$");
 Matcher m=p.matcher(str_zip_code);
 boolean matchFound = m.matches();
if(matchFound)
 {
 System.out.println("Zip/Postal Code format is ok.");
 }
 else
 {
 System.out.println("Wrong Zip/Postal Code format.");
 }
 }
}
Function is_valid_zip_code($str_zip_code)
{
 if (preg_match('/^([0-9]{5})(-[0-9]{4})?$/i',$str_zip_code))
{
     echo "Zip/Postal Code format is ok.";
 }
 else
 {
     echo "Wrong Zip/Postal Code format.";
 }
}

Validate Domain Name eg: http://live.com

?View Code JAVASCRIPT
function is_valid_url(str_url)
{
 var filter =   /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/
 if (!filter.test(str_url))
 {
 alert(’Wrong URL format.’);
 }
 else
 {
 alert('URL format is ok.')
 }
 return false;
}
?View Code CSHARP
 using System.Text.RegularExpressions;
 private void is_valid_url(string str_url)
 {
Regex matchRegex = new Regex(@"(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?");
 MatchCollection matches  = matchRegex.Matches(str_url);
 if(matches.Count==0)
 {
 Response.Write("Wrong URL format."); // In Webserver
 //MessageBox.Show("Wrong URL format."); //In Windows Form
 }
 else
 {
 Response.Write("URL format is ok."); // In Webserver
 //MessageBox.Show("URL format is ok."); //In Windows Form
 }
 }
Imports System.Text.RegularExpressions
 
Private Sub is_valid_url(ByVal str_url As String)
    Dim matchRegex As New Regex("(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?")
    Dim matches As MatchCollection = matchRegex.Matches(str_url)
    If matches.Count = 0 Then
        Response.Write("Wrong URL format.") ' In Webserver
        'MessageBox.Show("Wrong URL format."); 'In Windows Form
    Else
        Response.Write("URL format is ok.")    ' In Webserver
        'MessageBox.Show("URL format is ok."); 'In Windows Form
    End If
End Sub
import java.util.regex.*;
public class is_valid_url
{
 public static void main(String str_url)
 {
 Pattern p=Pattern.compile("(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?");
 Matcher m=p.matcher(str_url);
 boolean matchFound = m.matches();
 if(matchFound)
 {
 System.out.println("URL format is ok.");
 }
 else
 {
 System.out.println("Wrong URL format.");
 }
 }
}
Function is_valid_url($str_url)
{
 if (preg_match('/^([0-9]{5})(-[0-9]{4})?$/i',$str_url))
 {
     echo "URL format is ok.";
 }
 else
 {
     echo "Wrong URL format.";
 }
}

Create PHP Desktop Applications – Calculator

Thursday, March 5th, 2009

Introduction

As for PHP, Web is already known as a server-side language for creating applications, PHP-GTK2 and make use of the extension, PHP allows you to create applications that run on the desktop. In this paper, the PHP-GTK2 try to create a simple calculator for desktop use.

Audience

If you want to create PHP applications on the desktop

Environmental Building

Target OS is, Linux and Windows.

PHP-GTK2 is, PHP-GTK can be downloaded for free from our site.

For Windows, “php-gtk-2.**.**-win32-nts.zip” to download and unzip the file.

Basic configuration is at least close.

Sample program “Simple Calculator”

Then use the PHP-GTK2, let’s create a simple calculator. The following shows the source.

File name: calculator.php

<? php
class Calc (
private $ txt_1;
private $ txt_2;
private $ txt_3;
private $ tblTable;
private $ hbox_1;
private $ wnd1;
private $ cboCBox;
private $ calc_btn;
 
public function __construct () (
/ / Initialize the text box for numeric input
$ this-> txt_1 = new GtkEntry ();
$ this-> txt_2 = new GtkEntry ();
/ / Initialize display box solution for
$ this-> txt_3 = new GtkEntry ();
/ / Adjust the width of each text box,
$ this-> txt_1-> set_width_chars (6);
$ this-> txt_2-> set_width_chars (6);
$ this-> txt_3-> set_width_chars (6);
 
/ / Initialize the cboCBox box selection operator
$ this-> cboCBox = GtkcboCBoxBox:: new_text ();
$ this-> cboCBox-> insert_text (0 ,"+");
$ this-> cboCBox-> insert_text (1 ,"-");
$ this-> cboCBox-> insert_text (2 ,"×");
$ this-> cboCBox-> insert_text (3 ,"÷");
Appear to //"+" initial
$ this-> cboCBox-> set_active (0);
 
/ / Initialize the calculation button
$ this-> calc_btn = new GtkButton ("=");
 
/ / Assign the event listener
$ this-> calc_btn-> connect_simple ( "clicked", array ($ this, "calcHandler"));
 
/ / Initialize the table
$ this-> tblTable = new GtkTable (1, 5);
/ / Place the components on the table
$ this-> tblTable-> attach ($ this-> txt_1, 0,1,0,1);
$ this-> tblTable-> attach ($ this-> cboCBox, 1,2,0,1);
$ this-> tblTable-> attach ($ this-> txt_2, 2,3,0,1);
$ this-> tblTable-> attach ($ this-> calc_btn, 3,4,0,1);
$ this-> tblTable-> attach ($ this-> txt_3, 4,5,0,1);
 
$ this-> hbox_1 = new Gtkhbox_1 ();
$ this-> hbox_1-> pack_start ($ this-> tblTable);
$ this-> wnd1 = new GtkWindow ();
$ this-> wnd1-> add ($ this-> hbox_1);
$ this-> wnd1-> set_title ( "PHP Calculator");
$ this-> wnd1-> show_all ();
Gtk:: main ();
)
public function calcHandler () (
$ num1 = doubleval ($ this-> txt_1-> get_text ());
$ num2 = doubleval ($ this-> txt_2-> get_text ());
switch ($ this-> cboCBox-> get_active ()) (
/ / Add
case 0:
$ this-> txt_3-> set_text ($ num1 + $ num2);
break;
/ / Subtraction
case 1:
$ this-> txt_3-> set_text ($ num1 - $ num2);
break;
/ / Multiplication
case 2:
$ this-> txt_3-> set_text ($ num1 * $ num2);
break;
/ / Division default:
$ this-> txt_3-> set_text ($ num1 / $ num2);
)
)
)
/ / Calc, create an instance of the class
 
$ calc = new Calc ();
 
?>

Run the application

Let’s run this application. Open a command prompt, when you could just download the folder php-gtk2. Then, please run the following command:

C:\php-gtk2> php.exe calculator.php

Result

PHP App

If you want to quit the application, or applications [×] button on the command line [Ctr] + [C] Please run the shortcut key.

Commentary

Calc components are defined in the class.

Components used in this
GtkEntry Text box.
GtkComboBox Combo box.
GtkButton Button.
GtkTable Table. Placing a child in a grid component.
GtkHBox Horizontal box to hold the table.
GtkWindow Window to store the horizontal box.

GtkEntry and GtkComboBox, GtkButton and small components, GtkTable and place it in a container. To create a GtkTable this, new GtkTable(1,5) and a vertical length, the length of the next five and a specified grid. GtkTable to the placement of components, as follows: attach use the function.

$ this-> tblTable-> attach ($ this-> txt_1, 0,1,0,1);

Then put the components placed GtkHBox GtkTable objects. GtkHBox is the horizontal component of the box. The horizontal box is placed in the following pack_start use the function.

$ this-> hbox_1-> pack_start ($ this-> tblTable);

In addition, the box GtkHBox add this add to place a GtkWindow object.

$ this-> wnd1-> add ($ this-> hbox_1);

To set the title of the GtkWindow, set_title function.

$ this-> wnd1-> set_title ( "PHP Calculator");

Also, [=] to make the calculation for the function is called when pressing the button below.

$ this-> calc_btn-> connect_simple ( “clicked”, array ($ this, “calcHandler”));
Signal “clicked”, ie when I click “calcHandler” means that the function is called.

calcHandler Let’s look at the contents of the function.

$ num1 = doubleval ($ this-> txt_1-> get_text ());
$ num2 = doubleval ($ this-> txt_2-> get_text ());

txt_1, txt_2 the figures obtained in doubleval to quantify explicitly the function, each variable $ $num1 $ $num2 assigns.

Then, the index of the operator is selected in the combo box of the operator get_active Get function.

$ this-> cboCBox-> get_active ()

And in this case, the index

0 addition, if
If a subtraction
If you multiply two
If the three division
Has been set.

Calc Thus we complete the application to generate the last instance of the class.

$ calc = new Calc ();

Conclusion

This time I made a PHP-GTK2 applications running on their desktop calculator use. PHP-GTK in the rich component than what’s used.

PHP is a desktop application that is not made aware of the opportunity that this PHP-GTK2 to even try to challenge?

It may spread to new worlds.

References

PHP-GTK user guide

Ajax Based Search Engine With PHP and XML

Sunday, February 15th, 2009

Here Sample code of Ajax based search engine with PHP and XML

live_preview Live Preview          downloadDownload Code

 

This is the Javascript Code :

?View Code JAVASCRIPT
/* &lt;--------------------------&gt; */
/* XMLHTTPRequest Enable		*/
/* &lt;--------------------------&gt; */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}
 
var http = createObject();
 
/* &lt;--------------------------&gt; */
/* 		SEARCH				   */
/* &lt;--------------------------&gt; */
 
function fnSearchName() {
 
txtInput=encodeURI(document.getElementById('txtInput').value);
 
document.getElementById('divmsg').style.display = "block";
document.getElementById('divmsg').innerHTML = "Searching for <strong>" + txtInput+"</strong>";
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'php_Search.php?name='+txtInput+'&amp;nocache = '+nocache);
 
http.onreadystatechange = fnSearchNameReply;
http.send(null);
}
function fnSearchNameReply() {
 
	var response = http.responseText;
	document.getElementById('divResult').innerHTML=response;
 
}

This is the PHP Code :

load("NameList.xml");
$x=$xmlDoc-&gt;getElementsByTagName('NAME');
for ($i=0; $i&lt;=$x-&gt;length-1; $i++)
{
//Process only element nodes
if ($x-&gt;item($i)-&gt;nodeType==1)
  {
  if ($x-&gt;item($i)-&gt;childNodes-&gt;item(0)-&gt;nodeValue == $q)
    {
    $y=($x-&gt;item($i)-&gt;parentNode);
    }
  }
}
$cd=($y-&gt;childNodes);
for ($i=0;$i&lt;$cd-&gt;length;$i++)
{
//Process only element nodes
if ($cd-&gt;item($i)-&gt;nodeType==1)
  {
  echo($cd-&gt;item($i)-&gt;nodeName);
  echo(": ");
  echo($cd-&gt;item($i)-&gt;childNodes-&gt;item(0)-&gt;nodeValue);
  echo("");
  }
}
 
?&gt;