I am creating a login sessin in php. In first part index.html takes in text for AUTH_NAME and password in AUTH_PASSWD.
In the login.php I set these variables as global with session_register("AUTH_NAME") and session_register("AUTH_PASSWD").
code: index.html
<html>
<center><h2>Login</h2>
<form action=login.php method="post">
<table align=center>
<tr><td>User</td> <td><input type=text name=AUTH_NAME size="20"></td></tr>
<tr><td>Password</td><td><input type=password name=AUTH_PASSWD size="20"></td></tr>
<tr><td><input type="submit" value="Login!"></td></tr>
</form>
code: login.php
<?php
include("conf/conf.php");
if($pw=file($PWD_FILE)) $authenticated = 0;
session_register("AUTH_NAME");
session_register("AUTH_PASSWD");
for($i=0; $i<=count($pw); $i++)
{
$line = split(":", $pw[$i], -1);
$pass = chop($line[1]);
$salt = substr($pass, 0, 2);
$ToCompare=$AUTH_NAME.":".crypt($AUTH_PASSWD, $salt);
if(strcmp(trim($pw[$i]),$ToCompare)==0)
{
$authenticated=1;
echo $authenticated;
}
}
?>
in the conf.php I set up the password file like:
$PWD_FILE = '.../www/users';
I try to use AUTH_NAME and AUTH_PASSWD in the next lines but error_log tells that these variables are undefined:sad: .
Help