Ok. i'm going to include the code for my user authentication. the usernames and passwords are stored in a (mySQL)table called "writers"
--------***
<?php
include "include_fns.php";
include "header.php";
if ( (!$username) || (!$password) ) {
print "<h2>You must enter your username and password to proceed</h2>";
exit;
}
if (login($username, $password)) {
$auth_user = $username;
session_register("auth_user");
header("Location: $HTTP_REFERER");
}
else {
print "<h2>The password you entered is incorrect</h2>";
exit;
}
?>
---***
i include the following: 'include_fns.php'
which actually contains 3 includes inside of that. the following is include_fns.php:
---***
<?
include_once("db_fns.php");
include_once("user_auth_fns.php");
include_once("select_fns.php");
session_start();
?>
---***
and here is the code for "user_auth_fns.php"
which is where i believe i'm getting my error, or one of the errors.
---***
<?
function login($username, $password)
// check username and password with db
// if yes, return true
// else return false
{
// connect to db
$conn = db_connect();
if (!$conn)
return 0;
$result = mysql_query("select * from writers
where username='$username'
and password = password('$password')");
if (!$result)
return 0;
if (mysql_num_rows($result)>0)
return 1;
else
return 0;
}
function check_auth_user()
{
global $auth_user;
if ( (session_is_registered("auth_user")) && (isset($auth_user)) )
return true;
else
return false;
}
?>
---***
This is everything i'm using for user authentication, thus far. I'm not sure, but what i believe is that i'm starting a session once, but not maintaining that same session. I'm not sure if it terminates, or what. Anyway any help is greatly appreciated!
thanks
matthew koosy