main.php
<html>
<head><TITLE>Check User Name</TITLE>
<script language="JavaScript" src="jsFile.js" type="text/javascript"></script>
</head>
<body>
<table align="center" border="0">
<TR>
<TD><h3>Check User Name</h3></TD>
</TR>
<TR>
<TD height="10"> </TD>
</TR>
<TR>
<TD>Username</TD>
<TD>
<input type="text" name="txtName" id="txtName">
</TD>
</TR>
<TR>
<TD>Password</TD>
<TD>
<input type="text" name="txtpass" id="txtpass">
</TD>
</TR>
<TR><TD colspan='2' align='center'> <span id='resSpan'> </span></TD></TR>
<TR><TD colspan='2' align='center'> <input type='button' value='Check User' onclick='chkLogin()'></TD></TR>
</table>
</body>
</html>
jsFile.js
function chkLogin()
{
var nameVal=$("#txtName").val();
var pwd==$("#txtpwd").val();
var url=checkLogin.php';
var data='name='+nameVal+'&pwd='+pwd;
$.ajax({
type: "POST",
url: url
data: data,
success: function(msg){
document.getElementById('resSpan').innerHTML=msg;
}
});
}
checkLogin.php
<?php
// Db connection edit with your db connection parameters
$conn=mysql_connect("localhost","root","root");
$db=mysql_select_db("dbUserlogs");
$username'=trim($_POST['name']);
$pwd=$_POST['pwd'];
if(!empty($username)){
$sqlqry="SELECT * FROM user_entity where user_name='$username'";
$res=mysql_query($sqlqry) or die(mysql_error());
$count=mysql_num_rows($res);
if($count==0){
$msg='The user '+$username +'does not exist';
}else{
$sqlqry="SELECT * FROM user_entity where user_name='$username' and password='$pwd'";
$res=mysql_query($sqlqry) or die(mysql_error());
$count=mysql_num_rows($res);
if($count==0){
$msg="Incorrect Password!";
}else{
$msg="valid login!";
}
}else{
$msg='Enter username';
}
echo $msg;
?>
[Saturday, May 02, 2009
|
0
comments
]
Popular Posts
- MySQL stored procedure&triggers
- php questions
- Php Questions
- How we canmove into last changed position on info window close event On google map
- Pattern Matching in mysql
- MySQL INDEX
- MYSQL joins
- Jquery based dynamic adding and removal of html elements.
- securing a form with captcha
- Comparing a date with current date
0 comments
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.