I have my data in MySQL database is
'1', 'Demo', 'Demo1', 'Test'
On line 'echo $row[2]' it gives error "Notice: Undefined offset: 2"
Any solutions..?? PHP Code is as below...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$uname=$_POST['txtUserName'];
$passwd=$_POST['txtPassword'];
$query="SELECT usernm,passwd FROM tbuserdemo WHERE usernm='$uname'";
$result= mysql_query($query);
$rows= mysql_num_rows($result);
if($rows==0)
{
echo "User Name is Wrong";
}
else
{
$row=mysql_fetch_row($result);
$encpasswd= encrypt(1, $passwd);
if ($row[1]==$encpasswd)
{
echo "Welcome $uname";
echo $row[2];
}
else
{
echo "Password is Wrong";
}
}
?>
</body>
</html>
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.