I am writing a simple program where i have a HTML page that gets the username and password from the user and sends it to a PHP page. The PHP page connects to an MS access database and retrieves the stored password, compares it with the password given by the user and redirects the user appropriately. The following is the code.
<?php
$username = $_GET["fname"];
$userpass = $_GET["lname"];
$conn = odbc_connect('db1','','');
echo "hello ";
if (!$conn)
{exit("Connection Failed: " . $conn);}
echo "hello2";
$sql="SELECT * FROM login where `username`= $username";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
odbc_fetch_row($rs);
$dbpass = odbc_result($rs,"password");
if(strcmp($dbpass,$userpass))
header( 'Location: mainpage.html' );
else
header( 'Location: index.html' );
odbc_close($conn);
?>
The following is my error.
Warning: odbc_connect() [function.odbc-connect]: SQL error: Failed to fetch error message, SQL state HY000 in SQLConnect in C:\wamp\www\MyFiles\hello.php on line 6
what have I done wrongly??
Please help.