Help needed with a "simple" login script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Flexamill
Forum Newbie
Posts: 1
Joined: Thu Feb 07, 2008 9:00 am

Help needed with a "simple" login script

Post by Flexamill »

:banghead: No encryption. Right thye problem i have is that im a complete noob. I wonder if anyone could help me?

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
User avatar
hannnndy
Forum Contributor
Posts: 131
Joined: Sat Jan 12, 2008 2:09 am
Location: Iran>Tehran
Contact:

Re: Help needed with a "simple" login script

Post by hannnndy »

Code: Select all

Execute($sSQL);
1.the above method should return a boolean value right?
2.change the sql
"SELECT count (id) FROM tbllogin WHERE fldusername='$user'; AND fldpassword='$pass';"
into
"SELECT count (id) FROM tbllogin WHERE fldusername='". $user ."' AND fldpassword='". $pass ."'"
3. i do not have idea about your classes ad your methods

no. 2 should work
User avatar
hannnndy
Forum Contributor
Posts: 131
Joined: Sat Jan 12, 2008 2:09 am
Location: Iran>Tehran
Contact:

Re: Help needed with a "simple" login script

Post by hannnndy »

Code: Select all

Execute($sSQL);
1.the above method should return a boolean value right?
2.change the sql
"SELECT count (id) FROM tbllogin WHERE fldusername='$user'; AND fldpassword='$pass';"
into
"SELECT count (id) FROM tbllogin WHERE fldusername='". $user ."' AND fldpassword='". $pass ."'"
3. i do not have idea about your classes ad your methods

no. 2 should work
Post Reply