Jump to content

Login Problems with MS Access....please help!


yddib

Recommended Posts

I have to create a login that allows managers, admin and employees to login. I have a MS Access db called employees and the table is Details. This is the code for the login page:

 

<html>

<body>

<form name="form1" method="post" action="test1.php">

 

Username:

<input name="username" type="text" id="username" size="20"><br />

Password:

<input name="pass" type="text" id="pass" size="20"><br />

<input type="submit" name="Submit" value="Login">

</form>

</body>

</html>

 

The test1.php page is:

 

<html>

 

<head>

<title>New Page 1</title>

</head>

 

<body>

<?php

 

// Get the data collected from the user

$username =$_POST["username"];

$pass=$_POST["pass"];

 

///create an instance of  the  ADO connection object

$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");

 

//define connection string, specify database driver

$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Databases\employees.mdb";

//Open the connection to the database

  $conn->open($connStr);

 

echo "Connection Open<br>";

$SQL = "SELECT * FROM Details WHERE username = '$username' AND  password= '$password'";

 

$results = odbc_exec($sql);

if(count($results) == 1)

{

header("Location: manager1.php"); //forward user to new page

exit();

}

else{ // zero or more then one result found

echo "sorry, your username and password weren't found";

}

 

?>

</body>

 

</html>

 

I keep getting the else response when I enter my username and password even though they are correct. Now I am also getting Warning: Wrong parameter count for odbc_exec() in C:\wamp\www\test1\test1.php on line 28

 

If anyone could please point me in the right direction I would really appreciate it.

Thanks

Link to comment
https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/
Share on other sites

Thank you for being so patient!

It didn't make any difference with the upper case but I changed them both to lower case and echo $sql and it returned:

Connection Open

SELECT * FROM Details WHERE username = 'manager1' AND password= ''

Warning: Wrong parameter count for odbc_exec() in C:\wamp\www\test1\test1.php on line 28

 

 

Now I'm not sure but does that look like my password isn't being recognised? Or is it because it is a password field?

And am I even going about this the right way for what I need to do? Sorry I'm new to php!

 

 

Thanks so much. It helped the bit about my password not being echoed..........

 

Connection Open

SELECT * FROM Details WHERE username = 'manager1' AND password= 'qwerty'

Warning: Wrong parameter count for odbc_exec() in C:\wamp\www\test1\test1.php on line 28

sorry, your username and password weren't found

 

I'm just so confused! I've being trying to get it working all day!

try

<html>

<head>
<title>New Page 1</title>
</head>

<body>
<?php

// Get the data collected from the user
$username =$_POST["username"];
$pass=$_POST["pass"];

///create an instance of  the  ADO connection object
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");

//define connection string, specify database driver
$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Databases\employees.mdb";
//Open the connection to the database
$connect = $conn->open($connStr);

echo "Connection Open";
$sql = "SELECT * FROM Details WHERE username = '$username' AND  password= '$pass'";
$results = odbc_exec($connect,$sql);
if(odbc_num_rows($results) >= 1){
header("Location: manager1.php"); //forward user to new page
exit();
}
else{ // zero or more then one result found
echo "sorry, your username and password weren't found";
}

?>
</body>

</html>

Thank you again for your help but again it is bringing back more errors.

 

Connection Open

Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in C:\wamp\www\test1\test2.php on line 24

 

Warning: odbc_num_rows(): supplied argument is not a valid ODBC result resource in C:\wamp\www\test1\test2.php on line 25

sorry, your username and password weren't found

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.