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
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
Comment