Jump to content

Log In Help


yddib

Recommended Posts

I am trying to create a log in system with php and MSAccess

So far I have:

<html>

 

<head>

 

<title>Employee ID</title>

</head>

<body background="../../../Pictures/coolbg.jpg">

<p align="center"> </p>

<p align="center">

<img border="0" src="../../../Pictures/logo%20copy.jpg" width="570" height="143"></p>

<p align="center"> </p>

<form name="myform" method="POST" action="select1.php">

<p align="center">

  <p align="center">

  <font face="Arial">Employee ID:  <input type="text" name="id" size="20"></font></p>

  <p align="center"><font face="Arial">Password:      

  <input type="password" name="pass" size="20"></font></p>

  <p align="center"><font face="Arial">                               

  <input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></font></p>

 

 

</form>

<?php

// Main ----------

session_start();

 

// Get the data collected from the user

$Username =$_POST["id"];

$Password =$_POST["pass"];

 

//create an instance of  the  ADO connection object

$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");

 

//define connection string, specify database driver

$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=c:\wamp\www\samples\employees.mdb";

 

//Open the connection to the database

  $conn->open($connStr);

 

echo "Connection Open<br>";

 

 

 

$strSQL = "SELECT * FROM details WHERE Employee ID='$id' AND Password='$pass'";

$rs = $conn->execute($strSQL);

 

 

if ( $rs->Fields["id"]->value

&& $rs->Fields["id"]->value == $id

&& $rs->Fields["pass"]->value

&& $rs->Fields["pass"]->value == $pass

)

{

$_SESSION["authenticatedUser"] = $id;

// Relocate to the logged-in page

header("Location: select1.php");

 

}

else

{

$_SESSION["message"] = "Login Error as $id. " ;

header("Location: select.php");

}

 

?>

 

 

 

</body>

 

</html>

This is creating an error of:

Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft JET Database Engine<br/><b>Description:</b> Syntax error (missing operator) in query expression 'Employee ID='' AND Password='''.' in C:\wamp\www\samples\index.php:45 Stack trace: #0 C:\wamp\www\samples\index.php(45): com->execute('SELECT * FROM d...') #1 {main} thrown in C:\wamp\www\samples\index.php on line 45

 

The error is on: $strSQL = "SELECT * FROM details WHERE Employee ID='$id' AND Password='$pass'";

$rs = $conn->execute($strSQL);

 

 

But I cannot figure out what is wrong.

Any help would be greatly appreciated.

 

 

Link to comment
https://forums.phpfreaks.com/topic/96809-log-in-help/
Share on other sites

Thank you so much! That solved that problem......now there is a problem on line 48.

 

Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Field<br/><b>Description:</b> Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.' in C:\wamp\www\samples\index.php:48 Stack trace: #0 C:\wamp\www\samples\index.php(48): unknown() #1 {main} thrown in C:\wamp\www\samples\index.php on line 48

 

I realised I called the variable incorrectly but now I'm still having problems.

 

Sorry I am new to php!  ???

 

Link to comment
https://forums.phpfreaks.com/topic/96809-log-in-help/#findComment-495434
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.