Man you seem to be making this complicated, heres an system for you.
connect.inc is just your general db connection file. Which seemed to be fine from what I could see of the 6pt text.
I've even included the md5 encryption stuff for you 🙂
To add users... (assuming the HTML is correct)
<?php
$encpw=md5($password);
include ("connect.inc");
$query = "INSERT INTO table_name (real_name,user_name,password,level) VALUES ('$real_name','$user_name','$encpw','$level');";
$result = mysql_query($query);
mysql_close();
?>
Then to login from that and set a cookie...
Firstly check if the cookie is present, if so ignore the login form, if not present the form...
<?php
$encpw=md5($password);
if ($general_access == "lv1") {include "http://www.site.com/memberindex.htm";}
else {
if ($submit) {
include "connect.inc";
$result=mysql_query("select * from table_name where user_name='$user_name'",$db)
or die ("User Doesnt Exist!");
while ($row=mysql_fetch_array($result)) {
if ($row["password"] == $encpw) {include "setcookie.inc";}
else {echo "Incorrect information entered, please re-enter information";
die ("Wrong information entered!");}
}
}
include "login_form.inc";
}
?>
setcookie.inc..
<?php
setcookie ('general_access', 'lv1', time()+10800); header("Location: http://www.site.com/memberindex.htm");exit;}
?>
ie if the cookie is then set, the person must have logged in, so reload the page to the correct site, which they will be returned to without logging in for the next 3 hours.
loginform.inc is just another html form.
Hope this helps, its not that complex, just remember to make sure that the db has enough row spaces, for example, the password, whatever the length, is turned into 1 32bit md5 hash, setting varchar(8) therefore messes it up, I know!