yddib Posted March 19, 2008 Share Posted March 19, 2008 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 More sharing options...
teng84 Posted March 20, 2008 Share Posted March 20, 2008 $SQL = "SELECT * FROM Details WHERE username = '$username' AND password= '$password'"; $results = odbc_exec($sql); see the bold variables maybe that is what causing the error? Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496431 Share on other sites More sharing options...
yddib Posted March 20, 2008 Author Share Posted March 20, 2008 I don't think it made any difference... Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496434 Share on other sites More sharing options...
teng84 Posted March 20, 2008 Share Posted March 20, 2008 I don't think it made any difference... your using different variable lower case $sql which is empty try to echo that and see if there's no difference Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496436 Share on other sites More sharing options...
yddib Posted March 20, 2008 Author Share Posted March 20, 2008 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! Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496439 Share on other sites More sharing options...
teng84 Posted March 20, 2008 Share Posted March 20, 2008 $pass=$_POST["pass"]; $SQL = "SELECT * FROM Details WHERE username = '$username' AND password= '$password'"; sorry for the partial solution see bold characters hope that helps Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496440 Share on other sites More sharing options...
yddib Posted March 20, 2008 Author Share Posted March 20, 2008 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! Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496441 Share on other sites More sharing options...
jkewlo Posted March 20, 2008 Share Posted March 20, 2008 echo "sorry, your username and password weren't found"; is weren't a word? j/k hey im going to pm you give u some info im dealing with it right now. if u want some help Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496446 Share on other sites More sharing options...
yddib Posted March 20, 2008 Author Share Posted March 20, 2008 Thanks I just emailed u ther if that's ok. Personal messaging not working.......! And weren't? That's code from the net! & the least of my worries!! Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496449 Share on other sites More sharing options...
yddib Posted March 20, 2008 Author Share Posted March 20, 2008 Hi, I'm still really stuck, I'm not even sure if this code will do what I need it to do. Any recommendations would be great! Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496455 Share on other sites More sharing options...
teng84 Posted March 20, 2008 Share Posted March 20, 2008 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> Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496462 Share on other sites More sharing options...
yddib Posted March 20, 2008 Author Share Posted March 20, 2008 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 Link to comment https://forums.phpfreaks.com/topic/97009-login-problems-with-ms-accessplease-help/#findComment-496465 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.