[quote]
the problem which is i face is that while entering the username and password in the form and click the submit button it shows Wrong Username or Password
CODE
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$userpassword=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="userlogin"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$userpassword")or die("Cannot connect to the Data Base");
mysql_select_db("$db_name")or die("Cannot select DB");
// username and password sent from form
$loginname=$_POST['txtLoginName'];
$password=$_POST['(txtPassWord)'];
// To protect MySQL injection
$loginname = stripslashes($loginname);
$password = stripslashes($password);
$loginname = mysql_real_escape_string($loginname);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM userlogin WHERE $tbl_name='$loginname' and password='$password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("loginname");
session_register("password");
header("location:./login_success.php");
}
else {
//header("location:./main_login.php");
echo "Wrong Username or Password";
}
?>