i have altered the script as you said now i get this errors:
Notice: Undefined index: username in D:\wamp\www\inc\TMPh1hlhxx6mm.php on line 11
Notice: Undefined index: username in D:\wamp\www\inc\TMPh1hlhxx6mm.php on line 16
Notice: Undefined variable: username in D:\wamp\www\inc\TMPh1hlhxx6mm.php on line 30
Notice: Undefined variable: password in D:\wamp\www\inc\TMPh1hlhxx6mm.php on line 30
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\wamp\www\inc\TMPh1hlhxx6mm.php on line 30
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in D:\wamp\www\inc\TMPh1hlhxx6mm.php on line 30
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\wamp\www\inc\TMPh1hlhxx6mm.php on line 33
You are not authenticated. Please login.
The script is this:
PHP Code:
<?php
// Login & Session example by sde
// auth.php
error_reporting(E_ALL);
ini_set('display_errors',1);
// start session
session_start();
// convert username and password from _POST or _SESSION
if($_POST["username"])
{
$username=$_POST["username"];
$password=$_POST["password"];
}
elseif($_SESSION["username"])
{
$username=$_SESSION["username"];
$password=$_SESSION["password"];
}
// start and register session variables
session_register("username");
session_register("password");
// connect to database
include("connect.php");
// query for a user/pass match
$result=mysql_query("select * from users where username='" . $username . "' and password='" . $password . "'");
// retrieve number of rows resulted
$num=mysql_num_rows($result);
// print login form and exit if failed.
if($num < 1){
session_destroy();
echo "You are not authenticated. Please login.<br><br>
<form method=POST action=index.php>
username: <input type=text name=\"username\">
password: <input type=password name=\"password\">
<input type=submit>
</form>";
exit;
}
?>
I hope you appreciate my question.
I am a newbee
thanks