Jump to content

LOGIN code!! Won't work.......please help!!


yddib

Recommended Posts

I cannot get this code working and it should work!! I keep getting the else session error. Please help!

Thanks

 

<html>

<head>

<title>New Page 1</title>

</head>

 

<body>

 

<?php

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

$password = @$_POST['pass'];

 

$conn = new COM('ADODB.Connection') or die('Could not make conn');

$rs = new COM('ADODB.Recordset') or die('Coult not make rs');

 

$connstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\wamp\www\project\employees.mdb";

 

 

$conn->open($connStr);

if (!$conn)

  {exit("Connection Failed: " . $conn);}

$sql="SELECT username, password

FROM Details

WHERE username = '$username' AND  password= '$pass'";

$rs->Open($sql, $conn);

 

if (!$rs->EOF)

{

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

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

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

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

)

{

$_SESSION["auth"] = $username;

// Relocate to the logged-in page

header("Location: master1.php");

}

}

else

{

$_SESSION["error"] = "login Error as $username." ;

header("Location: main_login.php?error=Sign in error");

}

?>

</body>

 

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/97443-login-code-wont-workplease-help/
Share on other sites

what is "$rs->EOF" ?

 

this is obviously been set and giving u error, echo the query first, then try in phpmyadmin, if it wont work in phpmyadmin it probably wont work in any php script.

 

is your password hashed or encoded in the db? eg md5()?

 

are you absolutely sure your field names are exactly the same as in db, MySQL is case-sensitive on most platforms.

 

if the above dont help, try:

print_r($rs); exit(); 

put this before the if statement

 

hope this helps,

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.