I have a user authenication script that I am trying to make work with php version 4.0 to the newest version. Currently, it only works on 4.0 to 4.06. The script below has two things. One is a function that will register any variable. The second is a script that session registers the login and password and encrypts the password with md5. Here is the script I have which unfortunately needs major help. 🙁
function session_reg($var,$val)
{
if (phpversion() > 4.0)
{
$HTTP_SESSION_VARS[$var] = $val;
} else {
if (!session_is_registered($var))
{
session_register($var);
$GLOBALS[$var] = $val;
}
}
}
// make entered information global
$entered_login = $HTTP_POST_VARS['entered_login'];
$entered_password = $HTTP_POST_VARS['entered_password'];
if (phpversion() >= 4) {
// phpversion = 4
session_start();
$hash = session_id();
session_unregister("login");
session_unregister("password");
session_unregister("location");
}
$login = $entered_login;
// encrypt password if we can
if (function_exists(md5)) {
$password = md5($entered_password);
}
else {$password = $entered_password;}
if (phpversion() > 4.0) {
$page_title = $_SERVER["PHP_SELF"];
$HTTP_SESSION_VARS['login'] = $login;
$HTTP_SESSION_VARS['password'] = $password;
$HTTP_SESSION_VARS['location'] = $_SERVER["PHP_SELF"];
// make post variables global
} else {
$page_title = $PHP_SELF;
session_register("login");
session_register("password");
session_register("location");
}