Forum Moderators: coopster

Message Too Old, No Replies

php login scripts using odbc for ms acess database

php login using odbc msaccess

         

johns

4:50 am on Jul 12, 2010 (gmt 0)

10+ Year Member



I am new to php. i need the login required for admin pages. but i have to used ms access database using odbc (odbc.php) for odbc db connection. i am able to connect to db but, the login code (login.php) of which is show below. Unfortunatly isnot working. i modified the code from here [webmasterworld.com...]

here is my odbc connection
odbc.PHP
<?php $odbc= odbc_connect('store','','') or die('Could Not Connect to ODBC Database!'); ?>

here is login page not working Login.php
<?php require_once('odbc.php');

session_start();

// Get the data collected from the user
$logon_name =$_POST["logon_name"];
$logon_password =$_POST["logon_password"];


//$odbc->open($odbc);

$strSQL = "SELECT logon_name, logon_password FROM USERACCESS2 WHERE logon_name = '$logon_name' AND logon_password = '$logon_password'";
//$rs = $odbc->execute($strSQL);
$rs = odbc_exec($odbc, $strSQL);

if ($rs->Fields["logon_name"]->value && $rs->Fields["logon_name"]->value == $logon_name)
if ($rs->Fields["logon_password"]->value && $rs->Fields["logon_password"]->value == $logon_password)
{
$_SESSION["authenticatedUser"] = $logon_name;
// Relocate to the logged-in page
header("Location: loggedon.php");
}
else
{
$_SESSION["message"] = "login Error as $logon_name. " ;
header("Location: admin.php");
}
?>

also i would like check login on other admin page as well. your help would really appreciate. thanks

johns

3:54 am on Jul 13, 2010 (gmt 0)

10+ Year Member



can someone help me on this . i appreciate it

coopster

11:36 am on Jul 13, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, johns.

Could be more specific about "not working"? That may help the members here understand the issue.

johns

6:20 pm on Jul 13, 2010 (gmt 0)

10+ Year Member



thanks coopster.
after i enter username and pw when i click login it doesnt take me anywhere or doesnt give me error either. its stuck in login.php blank page. if user was accepted it should take me to loggedon.php or give me login error. "login Error as $logon_name. "
here is html form i am using. i think something wrong login.php code to connect to db.

<html>
<head>
<title>Login</title>
</head>
<body>
<form method="POST" action="login.php">
Username: <input type="text" name="logon_name" size="20">
Password: <input type="password" name="logon_password" size="20">
<input type="submit" value="Submit" name="login">
</form>
</body>
</html>

Matthew1980

7:47 pm on Jul 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there johns,

Greetings!

>>if user was accepted it should take me to loggedon.php or give me login error
<form method="POST" action="login.php">

Shouldn't that be loggedon.php, it won't function if you reference the wrong processing file :)

Could you post the relevant php script so that we can see a little clearer how you are handling the form being posted & processed?

The html there is fine though, it wouldn't validate as xhtml though, but I guess as you are aiming for transitional html there :)

Cheers,
MRb