hehe, well, I've got part of it working, but after spending ages trying the other part I've hit a brick wall.
Basically I'm setting a cookie if the username and password are correct, I'm first adding this information on another page, its just messing about to sort out HOW to do it before I actually install it on the site. I'm having a few levels of security, so that people who need to update the news, can't delete half the site for example.
Anyways... (cut down version!)
<?php
$lv1 = "lv1";
// and so on
if (($user_name == "") || ($password == "") || ($level == "")) {echo "Please enter information";}
?>
// table for entering real name, username, password, and level
<?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();
?>
So that works great, I've looked at my table and see this hideously long string for password 🙂
So, now to put it into practice...
<?php
$password=md5($checkpw);
if ($general_access == "lv1") {include "http://www.blah.com";}
// elseif statement for other levels
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"] == $password) {include "setcookie.inc";}
else {echo "Incorrect information entered, please re-enter information";
include "login.php";}
}
}
include "login_form.inc";
}
?>
login_form.inc is just a form asking for username and password, the password name is checkpw, which should be turned into an md5 hash, stored as $password, and then that compared to the one in the table, when they match, cookie set.
I've checked to make sure that the md5 string hash is the same for u6e and it is next time, ie doesn't change the encoding.
Just doesn't let me in!
Thanks for any help with this, I think I'm close, just can't make that last jump.