Login script
Posted: Sun May 07, 2006 11:47 am
feyd | Please use
The login form works, adminMenu() may work (haveb't tested it because can't log in.
The problem must be checkAdmin() / case "check".
Please help me
Thank you !
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Just another problem here...
What's the problem with this script?Code: Select all
<?
function adminForm(){
echo "<div align=\"right\" style=\"width:165px;\"><form action=\"?module=admin&file=admin&do=check\" method=\"post\">
Brukenavn: <input style=\"width:100px;\" type=\"text\" class=\"text\" name=\"uname\"><br>Passord: <input style=\"width:100px;\" type=\"password\" class=\"text\" name=\"passwd\"><br>
<input type=\"submit\" class=\"text\" value=\"Logg inn\">
</form></div>";
}
function checkAdmin($uname, $passwd){
$result = mysql_query("SELECT * FROM cw_user WHERE uname = '$username'");
$array = mysql_fetch_assoc($result) or die (mysql_error());
if($username == $array['uname'] and md5($password) == $array['passwd'] and $array['admin'] == 1){
$_SESSION["q6n4fk_logged_in"] = TRUE;
$_SESSION["q6n4fk_admin"] = TRUE;
$_SESSION["user"] = $uname;
echo "<meta content=\"3;URL=?module=admin&file=admin&do=menu\" http-equiv=\"refresh\">You've been logged in as $username.";
} else { echo "You've written a wrong combination of username and password!<br>a href=\"javascript:history.back(-1)\">Try again</a>"; }
}
function adminMenu(){
echo "Menu goes here!";
}
#################### Site starts here
$do = $_GET["do"];
$op = $_GET["op"];
switch ($do){
case "check":
$uname = $_POST["uname"];
$passwd = $_POST["passwd"];
checkAdmin($uname, $passwd);
break;
case "menu":
########### If not logged in, returns to admin login page
if(!$_SESSION["q6n4fk_admin"]){ echo "<meta content=\"0;URL=?module=admin&file=admin\" http-equiv=\"refresh\">"; } else {
adminMenu();
}
break;
default:
adminForm();
}
?>The problem must be checkAdmin() / case "check".
Please help me
Thank you !
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]