使用Ms Access ODBC进行简单登录 [英] Simple Login using Ms Access ODBC

查看:72
本文介绍了使用Ms Access ODBC进行简单登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的网页创建一个简单的登录,但我有点新手,无法看到我出错的地方任何帮助都会非常感激。


我'我正在使用访问数据库和ODBC。


我得到的代码如下;


[PHP]<?php


$ tbl_name =" tblCustomer" ;;


$ connstr =" DRIVER = {Microsoft Access Driver(* .mdb)}; DBQ = QUOT; 。 realpath(" 2PointB.mdb")。" ;;" ;;

$ conn = odbc_connect($ connstr,'''','''')或死亡(打印连接错误:" .odbc_error());


$ username = $ _ POST [''username''];

$ password = $ _ POST [''密码''];


$ username = stripslashes($ username);

$ password = stripslashes($ password);

$ sql =" SELECT * FROM $ tbl_name WHERE username =''$ username''and password =''$ password''" ;;

$ stmt = odbc_prepare($ conn,$ sql)或die(打印" odbc prepare error" .odbc_error());

$ result = odbc_exec($ stmt)或die(打印"结果错误" .odbc_error( ));


$ count = odbc_num_rows($ result);


if($ count == 1){


session_register(" username");

session_register(" password");

header(" location:/ wfolder / Logon2。 php");

}

else {

echo错误的用户名或密码;

}


odbc_close($ stmt);


?> [/ PHP]


谢谢

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="tblCustomer";

$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("2PointB.mdb").";";
$conn=odbc_connect($connstr,'''','''') or die(Print "connect error: ".odbc_error());

$username=$_POST[''username''];
$password=$_POST[''password''];

$username = stripslashes($username);
$password = stripslashes($password);

$sql="SELECT * FROM $tbl_name WHERE username=''$username'' and password=''$password''";
$stmt=odbc_prepare($conn, $sql) or die (Print "odbc prepare error".odbc_error());
$result=odbc_exec($stmt) or die (Print "result error ".odbc_error());

$count=odbc_num_rows($result);

if($count==1){

session_register("username");
session_register("password");
header("location:/wfolder/Logon2.php");
}
else {
echo "Wrong Username or Password";
}

odbc_close($stmt);

?>[/PHP]

Thanks

推荐答案

tbl_name =" tblCustomer" ;;

tbl_name="tblCustomer";


connstr =" DRIVER = {Microsoft Access Driver(* .mdb)}; DBQ = QUOT; 。 realpath(" 2PointB.mdb")。" ;;" ;;
connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("2PointB.mdb").";";


conn = odbc_connect(
conn=odbc_connect(


这篇关于使用Ms Access ODBC进行简单登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆