Help needed with a "simple" login script
Posted: Thu Feb 07, 2008 9:08 am
The code basically gets the data from textboxes on a form and compares to that of the fields in the database.
<?php
$user=$_POST['user'];
$pass=$_POST['pass'];
$adoCon = new COM("ADODB.Connection");
$slocation = dirname(__FILE__);
try
{ $adoCon->Open(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$slocation/databasename.mdb");
}
catch(Exception $e)
{ die('Sorry - Problem opening the database.<br />');
}
$sSQL = "SELECT count (id) FROM tbllogin WHERE fldusername='$user'; AND fldpassword='$pass';";
$result = ($sSQL,0); //should this be $rsmain instead of sql?
$rsMain = $adoCon->Execute($sSQL);
If ($result!=1) echo "Login Failed";
else{
echo "login success";
};
$adoCon->Close(); // Closes the connection.
$adoCon = null;
?>
Table has fields of id, fldusername, and fldpassword with sample data. I gotta be close. Also if anyone has some useful links/turoials that could solve this porblem id be grateful for those too.
Thanks for reading