Hi, I was wondering if anyone knew how to make a login in script (username/password) that can connect to a ODBC Microsoft Access Database. I just need the code to checked the Microsoft Access Database to see if the user has enterd the name and password correctly if they dont it rejects them. I would use MySQL but the guy does not want it, he just wants to stick with Microsoft Access. So can somone please help me out I have been looking all over. I dont even need the login page just the connection to check if the users are in the database. I have written scripts to show you what tables are there and add to them if somone wants to registar just need to touch it and say yes user is accepted. Thank you so much.
P.S. - If anyone needs a login script for MySql I can write one in 5min just let me know or any other scripts, I will help all I can since I am a newbie on this site.
PHP Login script with ODBC Microsoft Access
Moderator: General Moderators
PHP Login script with ODBC Microsoft Access
Last edited by Pointeo13 on Mon Jan 17, 2005 2:39 am, edited 1 time in total.
Thanks for the help, but the first link just shows how to fetch it, I can fetch my data np. I need to have it check to see if the user is granted access not fetch the data. But thanks majorly and such a fast reply.feyd wrote:http://www.phpfreaks.com/tutorials/61/0.php
http://us4.php.net/manual/en/function.odbc-connect.php
may be of interest..
If you can fetch tables, then you already have an odbc_connect(), right?
See this page in the manual and scoll down, the very first User Contributed Notes answers your question.
http://us3.php.net/manual/en/function.odbc-connect.php
You need to use odbc_exec(),odbc_fetch_row(), and odbc_result(), in that order.
See this page in the manual and scoll down, the very first User Contributed Notes answers your question.
http://us3.php.net/manual/en/function.odbc-connect.php
You need to use odbc_exec(),odbc_fetch_row(), and odbc_result(), in that order.
Ok this is what I have so far, all I can get it to do is to display the code, could somone help me how to make it just check the result and if the persons first name and last name is in the database then redirect them to a page. Just pretend that first name and last name is User name and Password. I was just using this as a test purpose later I will change the database names.
I have more code for it, but that just has it add the names in from the first page when they enter in there First name and last name. Well thanks again.
Code: Select all
<?php
function HTML_Head() {
echo "
<HTML><HEAD>
<TITLE>Processing Form</TITLE>
</HEAD>
<BODY BGCOLOR="#D5D5AB">";
}
function HTML_Foot() {
echo "</body></html>";
}
function Database_Entries($msg) {
echo $msg;
}
function Output_Entries() {
$cnx = odbc_connect( 'WebTute' , 'root', '' );
if (!$cnx) {
Error_handler( "Error in odbc_connect" , $cnx );
}
$cur= odbc_exec( $cnx, "select FirstName,LastName from Inputform" );
if (!$cur) {
Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
}
echo "<table border=1>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr>\n";
$nbrow=0;
while( odbc_fetch_row( $cur ) ) {
$nbrow++;
$FirstName= odbc_result( $cur, 1 ); // get the field "FirstName"
$LastName= odbc_result( $cur, 2 ); // get the field "LastName"
echo "
<tr>
<td>$FirstName</td>
<td>$LastName</td>
</tr>\n";
}
echo "<tr><td colspan=2>$nbrow entries </td></tr></table>";
odbc_close( $cnx);
}
function Error_Handler( $msg, $cnx ) {
echo "$msg \n";
odbc_close( $cnx);
exit();
}
?>