I am trying to create a simple login for my webpage, but Im a bit of a novice and cannot see where Im going wrong any help would be much appreciated.
I'm using an access database and ODBC.
The code I have got is below;
[PHP]<?php
$tbl_name="tblC ustomer";
$connstr = "DRIVER={Micros oft Access Driver (*.mdb)}; DBQ=" . realpath("2Poin tB.mdb").";";
$conn=odbc_conn ect($connstr,'' ,'') or die(Print "connect error: ".odbc_error()) ;
$username=$_POS T['username'];
$password=$_POS T['password'];
$username = stripslashes($u sername);
$password = stripslashes($p assword);
$sql="SELECT * FROM $tbl_name WHERE username='$user name' and password='$pass word'";
$stmt=odbc_prep are($conn, $sql) or die (Print "odbc prepare error".odbc_err or());
$result=odbc_ex ec($stmt) or die (Print "result error ".odbc_error()) ;
$count=odbc_num _rows($result);
if($count==1){
session_registe r("username") ;
session_registe r("password") ;
header("locatio n:/wfolder/Logon2.php");
}
else {
echo "Wrong Username or Password";
}
odbc_close($stm t);
?>[/PHP]
Thanks
15 8001
Assuming you have a separate login script/form that you have not shown here.
I am unable to guess about "where Im going wrong " and I really don't want to, so: what is the problem you encounter? Any error messages? What exactly does not work? What have you debugged so far in your code?
Ronald
Sorry I will try to clarify,
I have one HTML page with two input boxes on and it passes the variables username and password to this php script where I want to check to see if they are valid and if so send them to another page, if not then display message "Wrong Login".
Any other questions just ask.
I understand how it is supposed to work, but I asked you how you know it does not work and what problems you have! Like an error messgae, system hang, nothing at all, sql error, etc.
A more general remark on the code: do not use session_registe r, it is deprecated.
If you want your script to work regardless of register_global s, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_registe r(), it will not work in environments where the PHP directive register_global s is disabled.
Ronald
I get the result error. with out a odbc error number.
Your problem is in this statement[php]$result=odbc_ex ec($stmt) or die (Print "result error ".odbc_error()) ;[/php]This statement says: prepare and execute an sql statement. You have already prepared, so you must use[php]$result=odbc_ex ecute($stmt) or die (Print "result error ".odbc_error()) ;[/php]So:
odbc_exec — Prepare and execute a SQL statement
odbc_execute — Execute an already prepared statement
Ronald
Thanks very much, but unfortunatly i still get an 07001.
I cannot find the 7001 error code in the MySQL documentaiton, so why don't you just add the odbc error message to your output like[php]$result=odbc_ex ecute($stmt) or die (Print "result error ".odbc_error(). '-'.odbc_errormsg ());[/php]so you can see the error reason.
Ronald
Thanks, added it in the error reads
result error 07001-[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
I have tried looking checking that the names are right and everything but still no luck.
Also thanks for helping a novice you are helping more that you think.
Means you have not changed your odbc_exec into the odbc_execute statement. I.e. odbc_exec requires 2 parameters, odbc_execute requires 1 parameter.
And you really must use odbc_execute because you have already prepared the sql statement in the odbc_prepare!
Ronald
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: A.P. Madura |
last post by:
Need help in debugging this problem.
I have an access database which I use to demonstrate Java - ODBC
connectivity and it works perfectly fine. This allows me to assume
that the Data Source name definition is OK.
I tried to access the same DSN (system DSN) thro' PHP and the
following error is displayed.
Warning: odbc_connect() : SQL error:
|
by: TBone |
last post by:
Anyone,
I have a user "john" whose machine is part of the "job" domain. He is
trying to establish an odbc connection to an MS SQL 2000 server on the
"school" domain. He uses Windows authentication to establish the odbc
connection however it gives the error "Login failed for user '(null)'.
Reason: Not associated with a trusted SQL Server connection."
I am guessing that the odbc connection is trying to pass the
credentials of job\john...
|
by: calaha |
last post by:
Hi all,
I have been working with this since last night, and can't quite figure out
why it's not working. I have a simple login box form that is set to be my
startup form in my Access app (upon successful authentication, it opens the
Switchboard). All it does is get the username and password, pull up a
recordeset of the usernames and sets the UserId to be used throughout the
session. The table Userlist is a SQL 2000 linked table. I can...
|
by: jmev7 |
last post by:
Any way to avoid having to manually enter my user name & password for
the Oracle login box? I normally run a query on an attached Oracle
table and have to enter the un/pw before the query will run. There's
no place to enter this information in. Later, if I run subsequent
queries on the table in question, I don't need to enter un/pw again. I
can leave my PC on 24x7, but that's not really a solution. I need to
know if I can log in to the...
|
by: anand |
last post by:
Hi,
I have an Access 2000 database, which contains some native tables,
and some linked tables which belong to an ORACLE database, through
ODBC.
Using VB.NET, I am trying to fetch some data by joining two tables,
one table native to the mdb file, and another belonging to ORACLE.
I am using a connection string to connect to mdb file:
| |
by: N. Graves |
last post by:
Thank you for taking your time to read my question... please offer
your knowledge it will be appreciated!
I'm writing a ASP Web page to access a Access Database that has a
Database Password set. If I remove the password I'm able to read and
work with the database.
Here is the code that I have to open the connection to the Database:
Set objDB = Server.CreateObject("ADODB.Connection")
|
by: carl.manaster |
last post by:
I'm new to this game. I can find my way around C# without any trouble,
and I've used Access, a little bit, in the past. Now a friend wants an
application of mine to read from his Access database. He's sent me the
..mdb file and a username and password, also an .mdw security file, and
I've tried to connect to it, using a couple of sample programs I found
on the web. Here's the critical code (<path>, <user>, and <password>
of course...
|
by: lucy.randles |
last post by:
We're implementing automated logins to Oracle, using the users NT
password. However, when trying to link in tables through the ODBC
datasource in MS Access, we're encountering errors. Because users
local tables are kept on the domain, the path comes up as
domainname/username.tablename. It appears that Access doesn't like the
/, and therefore falls over. When linking tables that aren't proceded
by the / it works fine.
Is there any...
|
by: Greg Corradini |
last post by:
Hello all,
I'm having trouble inserting an SQL selection into a new MS Access table. I
get a parameter error on my insert statement when I try this (see below for
code and error msg). I'm not sure if 'insert' or 'update' is the route I
should be taking.
CODE:
#Import Pythond Standard Library Modules
import win32com.client, sys, os, string, copy, glob
import mx.ODBC.Windows as odbc
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |