tinkywonk Posted April 2, 2008 Share Posted April 2, 2008 Can some one help me i have a user database that i use to login to my site with some extra fields ie one being austria with a yes/no option. What i need to add to this code is to be able to filter the menu dependiong on if austria is set to yes or set to no out of the user database. The problem I have is I cannot seem to put the user name into a variable so i can pull up database for that user and see if i should filter the menu or no can some one help m mod this code please I have put commentas in code where i need help thanks <?php session_start(); if (isset($_GET["order"])) $order = @$_GET["order"]; if (isset($_GET["type"])) $ordtype = @$_GET["type"]; if (!isset($order) && isset($_SESSION["order"])) $order = $_SESSION["order"]; if (!isset($ordtype) && isset($_SESSION["type"])) $ordtype = $_SESSION["type"]; ?> <html> <head> <title></title> <meta name="generator" http-equiv="content-type" content="text/html"> <style type="text/css"> body { background-color: #3b506b; color: #FFFFFF; font-family: Arial; font-size: 12px; } .bd { background-color: #3b506b; color: #FFFFFF; font-family: Arial; font-size: 12px; } .tbl { background-color: #FFFFFF; } a:link { color: #FFFFFF; font-family: Arial; font-size: 12px; } a:active { color: #FFFFFF; font-family: Arial; font-size: 12px; } a:visited { color: #FFFFFF; font-family: Arial; font-size: 12px; } .hr { background-color: #506588; color: #FFFFFF; font-family: Arial; font-size: 12px; } a.hr:link { color: #FFFFFF; font-family: Arial; font-size: 12px; } a.hr:active { color: #FFFFFF; font-family: Arial; font-size: 12px; } a.hr:visited { color: #FFFFFF; font-family: Arial; font-size: 12px; } .ht { background-color: #3b506b; color: #FFFFFF; font-family: Arial; font-size: 20px; } a.ht:link { color: #FFFFFF; font-family: Arial; font-size: 20px; } a.ht:active { color: #FFFFFF; font-family: Arial; font-size: 20px; } a.ht:visited { color: #FFFFFF; font-family: Arial; font-size: 20px; } .hs { background-color: #3b506b; color: #FFFFFF; font-family: Arial; font-size: 20px; font-weight: bold; } a.hs:visited { color: #FFFFFF; font-family: Arial; font-size: 20px; font-weight: bold; } a.hs:link { color: #FFFFFF; font-family: Arial; font-size: 20px; font-weight: bold; } a.hs:active { color: #FFFFFF; font-family: Arial; font-size: 20px; font-weight: bold; } .dr { background-color: #FFFFFF; color: #000000; font-family: Arial; font-size: 12px; } .sr { background-color: #FFFFCF; color: #000000; font-family: Arial; font-size: 12px; } </style> <table class="bd" width="100%"><tr><td class="bd"><td align=center><h2><a class="ht" href="country.php?a=logout"><img src="images/background.jpg" border=0></a></h2></td></tr></table> </head> <body> ####this is my menu so if austria in user database is yes show the austria menu else dont####### <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="austria.php">[ Austria ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="benelux.php">[ Benelux ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="uk.php">[ UK ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="france.php">[ France ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="mcv.php">[ MCV ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="natgo.php">[ Natgo ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="poland.php">[ Poland ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="portugal.php">[ Portugal ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="spain.php">[ Spain ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="czech.php">[ Czech Republic ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="country.php?a=logout">[ Logout ]</a></td></tr></table> <br> <table class="bd" width="100%"><tr><td class="bd"><td align=center><a class="hs" href="setup.php?a=logout">[ Admin Setup ]</a></td></tr></table> </body> ####this is the login function where i need to change it to store if austria is es or no######### <?php function login() { global $_POST; global $_SESSION; global $_GET; if (isset($_GET["a"]) && ($_GET["a"] == 'logout')) $_SESSION["logged_in"] = false; if (!isset($_SESSION["logged_in"])) $_SESSION["logged_in"] = false; if (!$_SESSION["logged_in"]) { $login = ""; $password = ""; if (isset($_POST["login"])) $login = @$_POST["login"]; if (isset($_POST["password"])) $password = @$_POST["password"]; if (($login != "") && ($password != "")) { $conn = mysql_connect("server", "d", "pass"); mysql_select_db("db"); $sql = "select `Password` from `Users` where `user name` = '" .$login ."'"; $res = mysql_query($sql, $conn) or die(mysql_error()); $row = mysql_fetch_assoc($res) or $row = array(0 => "");; if (isset($row)) reset($row); if (isset($password) && ($password == trim(current($row)))) { $_SESSION["logged_in"] = true;} else { ?> <p><b><font color="FFFFFF">Sorry, the login/password combination you have entered is invalid</font></b></p> <?php } } }if (isset($_SESSION["logged_in"]) && (!$_SESSION["logged_in"])) { ?> <form action="country.php" method="post"> <table class="bd" border="0" cellspacing="1" cellpadding="4"> <tr> <td>Login</td> <td><input type="text" name="login" value="<?php echo $login ?>"></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password" value="<?php echo $password ?>"></td> </tr> <tr> <td><input type="submit" name="action" value="Login"></td> </tr> </table> </form> <?php } if (!isset($_SESSION["logged_in"])) $_SESSION["logged_in"] = false; return $_SESSION["logged_in"]; } ?> <?php function connect() { $conn = mysql_connect("mysql12.streamline.net", "natukcou1", "s132604"); mysql_select_db("natukcou1"); return $conn; } function sqlvalue($val, $quote) { if ($quote) $tmp = sqlstr($val); else $tmp = $val; if ($tmp == "") $tmp = "NULL"; elseif ($quote) $tmp = "'".$tmp."'"; return $tmp; } function sqlstr($val) { return str_replace("'", "''", $val); } any help will be appreciated thanks Link to comment https://forums.phpfreaks.com/topic/99185-need-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.