473,394 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

PhP Log In with Access DB

I am trying to log in using php and an Access db but it does not seem to be working, please help.

I have login.php, the user enters the username and password stored in the access db, php does some validation through php, connects to the database and logs in the user if the username and password are correct.

The column names in my Access db are called 'username' and 'password'.

This is my code:

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  
  3. $User = $_REQUEST['username'];
  4. $Password = $_REQUEST['password'];
  5. $adoCon = new COM("ADODB.Connection");
  6. $sHere = dirname(__FILE__);
  7.  
  8. Try
  9. {
  10.      $adoCon->Open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=$sHere/ses.accdb");
  11. }
  12. catch(Exception $e)
  13. {
  14.     die('Sorry - Error.<br />' . "[$sHere]<br />$e");
  15. }
  16.  
  17. $query = "SELECT * FROM tblStudent WHERE username = '$User' AND password = '$Password'";
  18. $rsMain = $adoCon->Execute($query);
  19.  
  20. if (!$rsMain->EOF)
  21. {
  22.     {
  23.     $dbUser = $rsMain->Fields("username")->value;
  24.     $dbUserPassword = $rsMain->Fields("password")->value;
  25.  
  26.     }
  27. if ($User==$dbUser&&$UserPassword==$dbUserPassword)
  28.     {
  29.           echo "Logged In <a href='index.php?p=profile'>Enter Home<a/>";
  30.         $_SESSION['username'] = $dbUser;
  31.     }
  32.   else
  33.  
  34.           echo "Sorry! <a href='index.php?p=login'>Retry:</a>";
  35. }
  36.   else
  37.  
  38.           echo ("Sorry! <a href='index.php?p=login'>Retry:</a>");
  39.  
  40. $rsMain->Close();
  41. $rsMain = null;
  42.  
  43. $adoCon->Close();
  44. $adoCon = null;
  45.  
  46. ?>
Nov 28 '13 #1
0 1147

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Frank Barnhart | last post by:
We have an application which runs Access under automation. With Access 97, the app included this line to send a report to a text file: myAccessObject.DoCmd.OutputTo acOutputReport, ,...
1
by: PamelaDV | last post by:
I am running into big problems with my Access 97 databases. I have one database in particular that needs to be repaired and compacted several times a day. I have problems when doing a repair and...
3
by: Mike Gramelspacher | last post by:
Hello, I have an Access 2000 database that I copied to a new computer with Access 2003. Access 2003 says the file is in Access 2000 file format. I made some changes to the Access 2000 file...
2
by: plau011 | last post by:
Hello Access gurus, I am curious as to why you can't open an Access 2003 Db with Access 2000. We have a Visual Basic application which is using DAO 3.6 to connect to the Access database. It IS...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
9
by: Bob Alston | last post by:
I am looking for electronic forms software that would integrate well with MS Access. I have a client for whom I built a client database to replace and update one they had that was obsolete and...
4
by: Balex | last post by:
Hi I have recently helped somebody converting an Access application into an Access (2002) front-end and an Oracle backend. It worked fine, until he decided to install and use Access 2007...
8
by: David | last post by:
Hi, I'm looking for advice on where to start with interfacing VB 2005 with Access 2003. For starters I would like to be able to add data to tables and retrieve queries from tables. Thanks, ...
8
by: marjbell | last post by:
I have a Access database of email addresses that I would like to mass email to customers. Can Access be used through Outlook? or can it just be done with Access? I know it is possible to use...
2
by: Ron Taylor | last post by:
I have inherited an Access 97 database with a VBA front end. I know nothing about VBA front ends, but can work with Access The system is vital to our organisation. At some point I will look at...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.