how to create login page using ajax?
i know whether to show valid or invalid in the same page..........
but how to redirect to same different page wen its and valid?

can you show me in your code where your problem is.

It's something like this:

document.location('approved.php');

window.location='approved.php';

document is used when working on the page, window is needed to manipulate frames or windows refreshing and redirection etc...

window.location('approved.php');

Aha, that's it ;)

window.location('approved.php');

sorry i forgot to mention that i am using html
this is my code

var xmlHttp=null;
	
	function getResult() {

		var name,password;
		name=document.login_frm.uname.value;
		password=document.login_frm.pwd.value;
		
		xmlHttp = GetXmlHttpObject();
		
		if (xmlHttp == null) {
			alert("Your browser does not support AJAX!")
			return;
		}

		var url = "/Login";
		url = url + "?q=" + name ;
		
		xmlHttp.onreadystatechange = stateChanged;
		
		xmlHttp.open("GET", url, true);
		
		xmlHttp.send(null);
	}
	function stateChanged() {
		if (xmlHttp.readyState == 4) {
			//document.writeln(xmlHttp.responseText);
			document.getElementById("Error").innerHTML = xmlHttp.responseText;
			
		}
	}

	function GetXmlHttpObject() {
		//var xmlHttp = null;
		try {
			// Firefox, Opera 8.0+, Safari
			xmlHttp = new XMLHttpRequest();
		} catch (e) {
			// Internet Explorer
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}
String name = request.getParameter("q");
		
		PrintWriter out = response.getWriter();	
       
		 Connection con = null;
		 PreparedStatement pstmt = null;
		 String query = null;
		 ResultSet rs=null;
		 query="select * from login where uname=? and pwd=?";
		 try{
				con=DBConnection.getInstance().getConnection();
				pstmt = con.prepareStatement(query);
				int cnt=1;
				pstmt.setString(cnt++,name);
				
				rs = pstmt.executeQuery();
				if(rs.next()){
					response.getWriter().write("valid");
					} else {
					response.getWriter().write("invalid");
								}
			}catch(SQLException e){
				e.printStackTrace();
						}
			out.close();

You can change this

if(rs.next()){					response.getWriter().write("valid");					} else {					response.getWriter().write("invalid");								}

into this:

if(rs.next()){					response.getWriter().write("valid");
                window.location("loginsucces.html");
					} else {					response.getWriter().write("invalid");								}

You can change this

if(rs.next()){					response.getWriter().write("valid");					} else {					response.getWriter().write("invalid");								}

into this:

if(rs.next()){					response.getWriter().write("valid");
                window.location("loginsucces.html");
					} else {					response.getWriter().write("invalid");								}

no that wont work becuase the server code is java and your writing in javascript.

You will have to write the window.location='page'

on your handler function like so

function stateChanged() {
   if (xmlHttp.readyState == 4) {
      if(xmlHttp.status==200){
        if( xmlHttp.responseText=="valid"){
           window.location='pagetogoto if valid';
      }
   }
  }
}