xyn Posted August 9, 2006 Share Posted August 9, 2006 Hi,I have a config file which Is attached to every page, withinthis config file I have a website closed script, this allowsthe admins to turn it on or off. the problem is with the SQLI have created it to check the users rank from a databaseif the rank is not an admin then they are redirected to myclosed page. However, when a member is not signed init doesn't affect them, neither does it if they are signed in.Is there any way around it?My code is...[code=php:0]$ssql = mysql_query("SELECT usr_rank FROM accounts WHERE usr_user='{$_SESSION['username']['usr_user']}'"); while( $sdat = mysql_fetch_array($ssql, MYSQL_NUM)) { if( $sdat[0] != admin ) { $sql = mysql_query("SELECT func_value FROM options WHERE op_id='1' AND func_name='web'"); while( $data = mysql_fetch_array($sql, MYSQL_NUM)) { $lock = $data[0]; if( $lock == y ) { echo '<meta http-equiv="REFRESH" content="0;URL=closed/index.php">'; exit; } } }else{ echo '<div align="center"> <center> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="50%" background="../template/images/bgmain.gif" height="20" bgcolor="#FFFFFF"> <tr> <td width="100%"> <p align="center"><b><font size="1" face="Verdana">MAINTENANCE MODE</font></b></td> </tr> </table> </center></div>'; } }[/code] Link to comment Share on other sites More sharing options...
ToonMariner Posted August 9, 2006 Share Posted August 9, 2006 yep before the query you could put an if statement.If no session the redirect to closed page.the query shoudl only retuen one result so get rid of the while loops.you if statement to see if they are admin is missing quotes around teh string.... 'admin' as is the lock if statement..... Link to comment Share on other sites More sharing options...
xyn Posted August 9, 2006 Author Share Posted August 9, 2006 Thanks for the advice :].and...it doesn't need quotes Unless it has a space or there is more than one variable like using && or || Link to comment Share on other sites More sharing options...
bltesar Posted August 9, 2006 Share Posted August 9, 2006 I can see a couple of possible problems here.First, you don't have 'admin' and 'y' in quotations in your conditionals.Second, I'm not sure that -echo '<meta http-equiv="REFRESH" content="0;URL=closed/index.php">';-will result in a redirect (if it does, I've learned something new-thanks). You might try header("Location:yourdomain.com/closed/index.php"); instead. Link to comment Share on other sites More sharing options...
bltesar Posted August 9, 2006 Share Posted August 9, 2006 correction, try try header("Location:http://www.yourdomain.com/closed/index.php"); instead. Link to comment Share on other sites More sharing options...
xyn Posted August 9, 2006 Author Share Posted August 9, 2006 1. my if statements don't need quotes " or ' i've tested it. 2. the META will redirect.because: 1. it's a HTML tag. and 2. if the headers are sent with Sessions, cookies or <head> using the META is the other solution to redirecting :/ Link to comment Share on other sites More sharing options...
Recommended Posts