Webocreation

Tuesday, August 11, 2009

php code for login with javascript



<!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=iso-8859-1" />

<title>colors2web</title>

<!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=iso-8859-1" />

<title>colors2wweb login</title>

<link href="style.css" rel="stylesheet" type="text/css" />

<script src="jquery.js" type="text/javascript" language="javascript"></script>

<script language="javascript">

// Developed by pusp raj joshi

//


$(document).ready(function()

{

$("#login_form").submit(function()

{

//remove all the class add the messagebox classes and start fading

$("#msgbox").removeClass().addClass('messagebox').text('Checking User in colors2web database....').fadeIn(1000);

//check the username exists or not from ajax

$.post("ajax_login.php",{ user_name:$('#username').val(),password:$('#password').val() } ,function(data)

{

if(data=='yes') //if correct login detail

{

$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox

{

//add message and change the class of the box and start fading

$(this).html('Logging in to the admin of colors2web.....').addClass('messageboxok').fadeTo(900,1,

function()

{

//redirect to secure page

document.location='main_login.php';

});


});

}

else

{

$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox

{

//add message and change the class of the box and start fading

$(this).html('You are not Administrator of colors2web...').addClass('messageboxerror').fadeTo(900,1);

});

}


});

return false; //not to post the form physically

});

//now call the ajax also focus move from

$("#password").blur(function()

{

$("#login_form").trigger('submit');

});

});

</script>

<link href="style.css" rel="stylesheet" type="text/css" />


<style type="text/css">

<!--

.style3 {font-size: 24px}

-->

</style>

</head>


<body>

<?php include('header.php');?>

<form method="post" action="" id="login_form">

<table width="511" height="188" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#0099FF">

<tr>

<td height="32" colspan="2"><div align="center">AGENT LOGIN </div></td>

</tr>

<tr>

<td width="70" height="32">Username </td>

<td width="583" height="32"><label>

<input type="text" name="username" id="username"/>

</label> </td>

</tr>

<tr>

<td height="32">Password</td>

<td height="32"><label>

<input type="Password" name="password" id="password"/>

</label></td>

</tr>

<tr>

<td height="39"><label></label></td>

<td align="left" valign="bottom">



<div align="left">

<input name="Submit" type="submit" class="button" value="&nbsp;&nbsp;login" style="margin-left:-10px; height:29px" />

<span id="msgbox" style="display:none"/>

</div></td></tr>



<tr>

<td height="23" colspan="2" align="center" valign="middle">Copyright &copy; 2009 colors2web.Com All rights reserved. </td>

</tr>

</table>

</form>

</body>

</html>

No comments:

Post a Comment