Xtremer360 Posted December 26, 2008 Share Posted December 26, 2008 My login part works correctly now however it goes to a white screen filled with nothing. What it should be doing is displaying the layout of my control panel but it is not. I know my scripting will have to be changed around but don't know where to move it to. <?php include ('database.php'); //if the login form is submitted if(isset($_POST['submit'])) { // makes sure they filled it in if(!$_POST['username'] || !$_POST['password']) { die('You did not fill in a required field.'); } $username = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['password']); $check = mysql_query("SELECT * FROM users WHERE username = '".$username."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database.'); } while($info = mysql_fetch_array( $check )) { $pass = md5(stripslashes($_POST['password'])); $info['password'] = stripslashes($info['password']); //$_POST['pass'] = md5($_POST['pass']); THIS IS DONE IN THE ABOVE STATEMENT //gives error if the password is wrong if ($pass != $info['password']) { die('Incorrect password, please try again.'); } else // if login is ok then we add a cookie and send them to the correct page { $username = stripslashes($username); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); // Finds out the user type $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $admin = $row['admin']; $_SESSION['admin'] = $admin; } } } else { // if they have not submitted the form ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Language" content="en-us"> <meta name="language" content="en-us"> <title>Backstage V1 Administration Console</title> <link rel="stylesheet" href="backstage.css" type="text/css" media="screen"> <link rel="stylesheet" href="backstage_print.css" type="text/css" media="print"> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script type="text/javascript" src="ajax.js"></script> <script type="text/javascript"> var page = document.cookie.match(/page=[\w][\w\-\.]+;/); if(page != null) { ajaxpage("page", "content"); } else { ajaxpage("home", "content"); } </script> <link rel=stylesheet href=backstage.css type=css media=screen> <link rel=stylesheet href=backstage_print.css type=css media=print> </head> <body> <div id=login> <form method="POST" action="/other/backstage2.php"> <h1>KOW Backstage</h1> <p><label>Username:<br><input type="text" name="username" id="log" tabindex="1"></label></p> <p><label>Password:<br><input type="password" name="password" id="pwd" tabindex="2"></label></p> <p style="text-align: center;"><input type="submit" class="button" name="submit" id="submit" value="Login »" tabindex="4"></p> </form> </div> <?php if(isset($_SESSION['admin'])) { ?> <div id=container> <div class=header> <table cellpadding="0" cellspacing="0" border="0" width="95%"> <tr> <td width=110 align=center></td> <td></td> <td width=40 valign=bottom align=right> <a href="#" onclick="ajaxpage('home', 'content'); return false;">Home</a> | <a href="#" onclick="ajaxpage('logout', 'content'); return false;">Logout</a> | <a target="_blank" href="http://kansasoutlawwrestling.com/phpBB3">Forums</a></td> </tr> </table> </div> <div id=container2> <div id=nav> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 1) { ?> <h1>Character</h1> <ul> <li><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></li> <li><a href="#" onclick="ajaxpage('allies', 'content'); return false;">Allies</a></li> <li><a href="#" onclick="ajaxpage('rivals', 'content'); return false;">Rivals</a></li> <li><a href="#" onclick="ajaxpage('quotes', 'content'); return false;">Quotes</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 4) { ?> <h1>Submit</h1> <ul> <li><a href="#" onclick="ajaxpage('roleplay', 'content'); return false;">Roleplay</a></li> <li><a href="#" onclick="ajaxpage('news', 'content'); return false;">News</a></li> <li><a href="#" onclick="ajaxpage('match', 'content'); return false;">Match</a></li> <li><a href="#" onclick="ajaxpage('seg', 'content'); return false;">Seg</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 3) { ?> <h1>Handler</h1> <ul> <li><a href="#" onclick="ajaxpage('directory', 'content'); return false;">Directory</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 2) { ?> <h1>Booking</h1> <ul> <li><a href="#" onclick="ajaxpage('champions', 'content'); return false;">Champions</a></li> <li><a href="#" onclick="ajaxpage('booker', 'content'); return false;">Booker</a></li> <li><a href="#" onclick="ajaxpage('compiler', 'content'); return false;">Compiler</a></li> <li><a href="#" onclick="ajaxpage('archives', 'content'); return false;">Archives</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 1) { ?> <h1>Fed Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('handlers', 'content'); return false;">Handlers</a></li> <li><a href="#" onclick="ajaxpage('characters', 'content'); return false;">Characters</a></li> <li><a href="#" onclick="ajaxpage('applications', 'content'); return false;">Applications</a></li> <li><a href="#" onclick="ajaxpage('eventnames', 'content'); return false;">Event Names</a></li> <li><a href="#" onclick="ajaxpage('titlenames', 'content'); return false;">Title Names</a></li> <li><a href="#" onclick="ajaxpage('matchtypes', 'content'); return false;">Match Types</a></li> <li><a href="#" onclick="ajaxpage('divisions', 'content'); return false;">Divisions</a></li> <li><a href="#" onclick="ajaxpage('countries', 'content'); return false;">Arenas</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 0) { ?> <h1>Site Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('templates', 'content'); return false;">Templates</a></li> <li><a href="#" onclick="ajaxpage('content', 'content'); return false;">Content</a></li> <li><a href="#" onclick="ajaxpage('biosconfig', 'content'); return false;">Bio Configuration</a></li> <li><a href="#" onclick="ajaxpage('newscat', 'content'); return false;">News Categories</a></li> <li><a href="#" onclick="ajaxpage('menus', 'content'); return false;">Menus</a></li> </ul> <?php } ?> </div> <div id=content> </div> <div id="footer">Backstage 1 © 2009 </div> </div> </div> </body> </html> <?php } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/ Share on other sites More sharing options...
Adam Posted December 26, 2008 Share Posted December 26, 2008 You're getting a white page because you're not sending them anywhere or printing anything to the screen. // if login is ok then we add a cookie and send them to the correct page { $username = stripslashes($username); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); // Finds out the user type $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $admin = $row['admin']; $_SESSION['admin'] = $admin; } Underneath "$_SESSION['admin'] = $admin" you need to add: header("Location: page/to/redirect/to.php"); A Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-723970 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 Well its to itself page it doesn't go to a different page. Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-723971 Share on other sites More sharing options...
Adam Posted December 26, 2008 Share Posted December 26, 2008 Perhaps rather than having the login tests on your home page, would be easier for you to create a login.php page? Then you can simply test if they have been logged in, redirect if so, or display an error. The way you're doing it at the minute is.. If they've submitted the login form, run the login tests, else, display the page. You're basically either displaying the page, or trying to log them in but not displaying no output if successful. Note the: } else { // if they have not submitted the form ?> ... just before your HTML. Try adding instead of the "header()" function: echo 'Login successful!'; A Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-723973 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 Well after login I'm wanting to display this part of my coding. <?php if(isset($_SESSION['admin'])) { ?> <div id=container> <div class=header> <table cellpadding="0" cellspacing="0" border="0" width="95%"> <tr> <td width=110 align=center></td> <td></td> <td width=40 valign=bottom align=right> <a href="#" onclick="ajaxpage('home', 'content'); return false;">Home</a> | <a href="#" onclick="ajaxpage('logout', 'content'); return false;">Logout</a> | <a target="_blank" href="http://kansasoutlawwrestling.com/phpBB3">Forums</a></td> </tr> </table> </div> <div id=container2> <div id=nav> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 1) { ?> <h1>Character</h1> <ul> <li><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></li> <li><a href="#" onclick="ajaxpage('allies', 'content'); return false;">Allies</a></li> <li><a href="#" onclick="ajaxpage('rivals', 'content'); return false;">Rivals</a></li> <li><a href="#" onclick="ajaxpage('quotes', 'content'); return false;">Quotes</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 4) { ?> <h1>Submit</h1> <ul> <li><a href="#" onclick="ajaxpage('roleplay', 'content'); return false;">Roleplay</a></li> <li><a href="#" onclick="ajaxpage('news', 'content'); return false;">News</a></li> <li><a href="#" onclick="ajaxpage('match', 'content'); return false;">Match</a></li> <li><a href="#" onclick="ajaxpage('seg', 'content'); return false;">Seg</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 3) { ?> <h1>Handler</h1> <ul> <li><a href="#" onclick="ajaxpage('directory', 'content'); return false;">Directory</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 2) { ?> <h1>Booking</h1> <ul> <li><a href="#" onclick="ajaxpage('champions', 'content'); return false;">Champions</a></li> <li><a href="#" onclick="ajaxpage('booker', 'content'); return false;">Booker</a></li> <li><a href="#" onclick="ajaxpage('compiler', 'content'); return false;">Compiler</a></li> <li><a href="#" onclick="ajaxpage('archives', 'content'); return false;">Archives</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 1) { ?> <h1>Fed Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('handlers', 'content'); return false;">Handlers</a></li> <li><a href="#" onclick="ajaxpage('characters', 'content'); return false;">Characters</a></li> <li><a href="#" onclick="ajaxpage('applications', 'content'); return false;">Applications</a></li> <li><a href="#" onclick="ajaxpage('eventnames', 'content'); return false;">Event Names</a></li> <li><a href="#" onclick="ajaxpage('titlenames', 'content'); return false;">Title Names</a></li> <li><a href="#" onclick="ajaxpage('matchtypes', 'content'); return false;">Match Types</a></li> <li><a href="#" onclick="ajaxpage('divisions', 'content'); return false;">Divisions</a></li> <li><a href="#" onclick="ajaxpage('countries', 'content'); return false;">Arenas</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 0) { ?> <h1>Site Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('templates', 'content'); return false;">Templates</a></li> <li><a href="#" onclick="ajaxpage('content', 'content'); return false;">Content</a></li> <li><a href="#" onclick="ajaxpage('biosconfig', 'content'); return false;">Bio Configuration</a></li> <li><a href="#" onclick="ajaxpage('newscat', 'content'); return false;">News Categories</a></li> <li><a href="#" onclick="ajaxpage('menus', 'content'); return false;">Menus</a></li> </ul> <?php } ?> </div> <div id=content> </div> <div id="footer">Backstage 1 © 2009 </div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-723975 Share on other sites More sharing options...
Adam Posted December 26, 2008 Share Posted December 26, 2008 Try what I said before; exporting your login code to another file (such as login.php) .. and redirect back to the current page on success. You should be able to test if they're logged in, in the same way you are doing now - assuming the session data has been setup correctly. A Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-723979 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 Problem is fixed and login works great and loads the control panel just fine but it still shows the login part below the CP. How do i fix that. Here's my updated code. <?php include ('database.php'); //if the login form is submitted if(isset($_POST['submit'])) { // makes sure they filled it in if(!$_POST['username'] || !$_POST['password']) { die('You did not fill in a required field.'); } $username = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['password']); $check = mysql_query("SELECT * FROM users WHERE username = '".$username."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database.'); } while($info = mysql_fetch_array( $check )) { $pass = md5(stripslashes($_POST['password'])); $info['password'] = stripslashes($info['password']); //$_POST['pass'] = md5($_POST['pass']); THIS IS DONE IN THE ABOVE STATEMENT //gives error if the password is wrong if ($pass != $info['password']) { die('Incorrect password, please try again.'); } else // if login is ok then we add a cookie and send them to the correct page { $username = stripslashes($username); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); // Finds out the user type $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $admin = $row['admin']; $_SESSION['admin'] = $admin; ######################################### ######## ADMIN SCRIPT CAN BE ADDED BELOW ######################################### if(isset($_SESSION['admin'])) { ?> <div id=container> <div class=header> <table cellpadding="0" cellspacing="0" border="0" width="95%"> <tr> <td width=110 align=center></td> <td></td> <td width=40 valign=bottom align=right> <a href="#" onclick="ajaxpage('home', 'content'); return false;">Home</a> | <a href="#" onclick="ajaxpage('logout', 'content'); return false;">Logout</a> | <a target="_blank" href="http://kansasoutlawwrestling.com/phpBB3">Forums</a></td> </tr> </table> </div> <div id=container2> <div id=nav> <?php } if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 1) { ?> <h1>Character</h1> <ul> <li><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></li> <li><a href="#" onclick="ajaxpage('allies', 'content'); return false;">Allies</a></li> <li><a href="#" onclick="ajaxpage('rivals', 'content'); return false;">Rivals</a></li> <li><a href="#" onclick="ajaxpage('quotes', 'content'); return false;">Quotes</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 4) { ?> <h1>Submit</h1> <ul> <li><a href="#" onclick="ajaxpage('roleplay', 'content'); return false;">Roleplay</a></li> <li><a href="#" onclick="ajaxpage('news', 'content'); return false;">News</a></li> <li><a href="#" onclick="ajaxpage('match', 'content'); return false;">Match</a></li> <li><a href="#" onclick="ajaxpage('seg', 'content'); return false;">Seg</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 3) { ?> <h1>Handler</h1> <ul> <li><a href="#" onclick="ajaxpage('directory', 'content'); return false;">Directory</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 2) { ?> <h1>Booking</h1> <ul> <li><a href="#" onclick="ajaxpage('champions', 'content'); return false;">Champions</a></li> <li><a href="#" onclick="ajaxpage('booker', 'content'); return false;">Booker</a></li> <li><a href="#" onclick="ajaxpage('compiler', 'content'); return false;">Compiler</a></li> <li><a href="#" onclick="ajaxpage('archives', 'content'); return false;">Archives</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 1) { ?> <h1>Fed Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('handlers', 'content'); return false;">Handlers</a></li> <li><a href="#" onclick="ajaxpage('characters', 'content'); return false;">Characters</a></li> <li><a href="#" onclick="ajaxpage('applications', 'content'); return false;">Applications</a></li> <li><a href="#" onclick="ajaxpage('eventnames', 'content'); return false;">Event Names</a></li> <li><a href="#" onclick="ajaxpage('titlenames', 'content'); return false;">Title Names</a></li> <li><a href="#" onclick="ajaxpage('matchtypes', 'content'); return false;">Match Types</a></li> <li><a href="#" onclick="ajaxpage('divisions', 'content'); return false;">Divisions</a></li> <li><a href="#" onclick="ajaxpage('countries', 'content'); return false;">Arenas</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 0) { ?> <h1>Site Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('templates', 'content'); return false;">Templates</a></li> <li><a href="#" onclick="ajaxpage('content', 'content'); return false;">Content</a></li> <li><a href="#" onclick="ajaxpage('biosconfig', 'content'); return false;">Bio Configuration</a></li> <li><a href="#" onclick="ajaxpage('newscat', 'content'); return false;">News Categories</a></li> <li><a href="#" onclick="ajaxpage('menus', 'content'); return false;">Menus</a></li> </ul> <?php } ?> </div> <div id=content> </div> <div id="footer">Backstage 1 © 2009 </div> </div> </div> <?php ######################################### ######## ADMIN SCRIPT HAS TO END ABOVE ######################################### } } } else { // if they have not submitted the form } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Language" content="en-us"> <meta name="language" content="en-us"> <title>Backstage V1 Administration Console</title> <link rel="stylesheet" href="backstage.css" type="text/css" media="screen"> <link rel="stylesheet" href="backstage_print.css" type="text/css" media="print"> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script type="text/javascript" src="ajax.js"></script> <script type="text/javascript"> var page = document.cookie.match(/page=[\w][\w\-\.]+;/); if(page != null) { ajaxpage("page", "content"); } else { ajaxpage("home", "content"); } </script> <link rel=stylesheet href=backstage.css type=css media=screen> <link rel=stylesheet href=backstage_print.css type=css media=print> </head> <body> <div id=login> <form method="POST" action="/other/backstage4.php"> <h1>KOW Backstage</h1> <p><label>Username:<br><input type="text" name="username" id="log" tabindex="1"></label></p> <p><label>Password:<br><input type="password" name="password" id="pwd" tabindex="2"></label></p> <p style="text-align: center;"><input type="submit" class="button" name="submit" id="submit" value="Login »" tabindex="4"></p> </form> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724036 Share on other sites More sharing options...
Adam Posted December 26, 2008 Share Posted December 26, 2008 Put the login HTML between the two curly braces: else { // if they have not submitted the form } A Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724041 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 Parse error: syntax error, unexpected '<' in /home/content/y/a/n/yankeefaninkc/html/other/backstage4.php on line 144 <?php include ('database.php'); //if the login form is submitted if(isset($_POST['submit'])) { // makes sure they filled it in if(!$_POST['username'] || !$_POST['password']) { die('You did not fill in a required field.'); } $username = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['password']); $check = mysql_query("SELECT * FROM users WHERE username = '".$username."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database.'); } while($info = mysql_fetch_array( $check )) { $pass = md5(stripslashes($_POST['password'])); $info['password'] = stripslashes($info['password']); //$_POST['pass'] = md5($_POST['pass']); THIS IS DONE IN THE ABOVE STATEMENT //gives error if the password is wrong if ($pass != $info['password']) { die('Incorrect password, please try again.'); } else // if login is ok then we add a cookie and send them to the correct page { $username = stripslashes($username); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); // Finds out the user type $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $admin = $row['admin']; $_SESSION['admin'] = $admin; ######################################### ######## ADMIN SCRIPT CAN BE ADDED BELOW ######################################### if(isset($_SESSION['admin'])) { ?> <div id=container> <div class=header> <table cellpadding="0" cellspacing="0" border="0" width="95%"> <tr> <td width=110 align=center></td> <td></td> <td width=40 valign=bottom align=right> <a href="#" onclick="ajaxpage('home', 'content'); return false;">Home</a> | <a href="#" onclick="ajaxpage('logout', 'content'); return false;">Logout</a> | <a target="_blank" href="http://kansasoutlawwrestling.com/phpBB3">Forums</a></td> </tr> </table> </div> <div id=container2> <div id=nav> <?php } if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 6) { ?> <h1>Character</h1> <ul> <li><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></li> <li><a href="#" onclick="ajaxpage('allies', 'content'); return false;">Allies</a></li> <li><a href="#" onclick="ajaxpage('rivals', 'content'); return false;">Rivals</a></li> <li><a href="#" onclick="ajaxpage('quotes', 'content'); return false;">Quotes</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 5) { ?> <h1>Submit</h1> <ul> <li><a href="#" onclick="ajaxpage('roleplay', 'content'); return false;">Roleplay</a></li> <li><a href="#" onclick="ajaxpage('news', 'content'); return false;">News</a></li> <li><a href="#" onclick="ajaxpage('match', 'content'); return false;">Match</a></li> <li><a href="#" onclick="ajaxpage('seg', 'content'); return false;">Seg</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 4) { ?> <h1>Handler</h1> <ul> <li><a href="#" onclick="ajaxpage('directory', 'content'); return false;">Directory</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 3) { ?> <h1>Booking</h1> <ul> <li><a href="#" onclick="ajaxpage('champions', 'content'); return false;">Champions</a></li> <li><a href="#" onclick="ajaxpage('booker', 'content'); return false;">Booker</a></li> <li><a href="#" onclick="ajaxpage('compiler', 'content'); return false;">Compiler</a></li> <li><a href="#" onclick="ajaxpage('archives', 'content'); return false;">Archives</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 2) { ?> <h1>Fed Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('handlers', 'content'); return false;">Handlers</a></li> <li><a href="#" onclick="ajaxpage('characters', 'content'); return false;">Characters</a></li> <li><a href="#" onclick="ajaxpage('applications', 'content'); return false;">Applications</a></li> <li><a href="#" onclick="ajaxpage('eventnames', 'content'); return false;">Event Names</a></li> <li><a href="#" onclick="ajaxpage('titlenames', 'content'); return false;">Title Names</a></li> <li><a href="#" onclick="ajaxpage('matchtypes', 'content'); return false;">Match Types</a></li> <li><a href="#" onclick="ajaxpage('divisions', 'content'); return false;">Divisions</a></li> <li><a href="#" onclick="ajaxpage('countries', 'content'); return false;">Arenas</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 1) { ?> <h1>Site Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('templates', 'content'); return false;">Templates</a></li> <li><a href="#" onclick="ajaxpage('content', 'content'); return false;">Content</a></li> <li><a href="#" onclick="ajaxpage('biosconfig', 'content'); return false;">Bio Configuration</a></li> <li><a href="#" onclick="ajaxpage('newscat', 'content'); return false;">News Categories</a></li> <li><a href="#" onclick="ajaxpage('menus', 'content'); return false;">Menus</a></li> </ul> <?php } ?> </div> <div id=content> </div> <div id="footer">Backstage 1 © 2009 </div> </div> </div> <?php ######################################### ######## ADMIN SCRIPT HAS TO END ABOVE ######################################### } } } else { // if they have not submitted the form <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Language" content="en-us"> <meta name="language" content="en-us"> <title>Backstage V1 Administration Console</title> <link rel="stylesheet" href="backstage.css" type="text/css" media="screen"> <link rel="stylesheet" href="backstage_print.css" type="text/css" media="print"> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script type="text/javascript" src="ajax.js"></script> <script type="text/javascript"> var page = document.cookie.match(/page=[\w][\w\-\.]+;/); if(page != null) { ajaxpage("page", "content"); } else { ajaxpage("home", "content"); } </script> <link rel=stylesheet href=backstage.css type=css media=screen> <link rel=stylesheet href=backstage_print.css type=css media=print> </head> <body> <div id=login> <form method="POST" action="/other/backstage4.php"> <h1>KOW Backstage</h1> <p><label>Username:<br><input type="text" name="username" id="log" tabindex="1"></label></p> <p><label>Password:<br><input type="password" name="password" id="pwd" tabindex="2"></label></p> <p style="text-align: center;"><input type="submit" class="button" name="submit" id="submit" value="Login »" tabindex="4"></p> </form> </div> </body> </html> } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724046 Share on other sites More sharing options...
revraz Posted December 26, 2008 Share Posted December 26, 2008 Look at the line and troubleshoot it, or at least quote it so we know where it is. Parse error: syntax error, unexpected '<' in /home/content/y/a/n/yankeefaninkc/html/other/backstage4.php on line 144 Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724049 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 Problem is fixed and is finally where it should be except for one thing. Controlling what the type of user can see and what they can't. Right now I have two users in my DB for testing. One is an admin and one is a non-admin. And the way you know that is how my DB is setup. My table has a field called admin. If there is a 1 for that user then they are an admin. If it houses a 2 then they are a non-admin. What I want my script to do is have it only load the correct functions on the left for each user. If they are an admin it will load sections 6,5,4,3,2, and 1 so all of them. If they are a non-admin then they only get to see sections 6 and 5. What do I need to add to my coding so that it will do just that. <?php include ('database.php'); //if the login form is submitted if(isset($_POST['submit'])) { // makes sure they filled it in if(!$_POST['username'] || !$_POST['password']) { die('You did not fill in a required field.'); } $username = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['password']); $check = mysql_query("SELECT * FROM users WHERE username = '".$username."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database.'); } while($info = mysql_fetch_array( $check )) { $pass = md5(stripslashes($_POST['password'])); $info['password'] = stripslashes($info['password']); //$_POST['pass'] = md5($_POST['pass']); THIS IS DONE IN THE ABOVE STATEMENT //gives error if the password is wrong if ($pass != $info['password']) { die('Incorrect password, please try again.'); } else // if login is ok then we add a cookie and send them to the correct page { $username = stripslashes($username); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); // Finds out the user type $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $admin = $row['admin']; $_SESSION['admin'] = $admin; ######################################### ######## ADMIN SCRIPT CAN BE ADDED BELOW ######################################### if(isset($_SESSION['admin'])) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Language" content="en-us"> <meta name="language" content="en-us"> <title>Backstage V1 Administration Console</title> <link rel="stylesheet" href="backstage.css" type="text/css" media="screen"> <link rel="stylesheet" href="backstage_print.css" type="text/css" media="print"> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script type="text/javascript" src="ajax.js"></script> <script type="text/javascript"> var page = document.cookie.match(/page=[\w][\w\-\.]+;/); if(page != null) { ajaxpage("page", "content"); } else { ajaxpage("home", "content"); } </script> <link rel=stylesheet href=backstage.css type=css media=screen> <link rel=stylesheet href=backstage_print.css type=css media=print> </head> <body> <div id=container> <div class=header> <table cellpadding="0" cellspacing="0" border="0" width="95%"> <tr> <td width=110 align=center></td> <td></td> <td width=40 valign=bottom align=right> <a href="#" onclick="ajaxpage('home', 'content'); return false;">Home</a> | <a href="#" onclick="ajaxpage('logout', 'content'); return false;">Logout</a> | <a target="_blank" href="http://kansasoutlawwrestling.com/phpBB3">Forums</a></td> </tr> </table> </div> <div id=container2> <div id=nav> <?php } if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 6) { ?> <h1>Character</h1> <ul> <li><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></li> <li><a href="#" onclick="ajaxpage('allies', 'content'); return false;">Allies</a></li> <li><a href="#" onclick="ajaxpage('rivals', 'content'); return false;">Rivals</a></li> <li><a href="#" onclick="ajaxpage('quotes', 'content'); return false;">Quotes</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 5) { ?> <h1>Submit</h1> <ul> <li><a href="#" onclick="ajaxpage('roleplay', 'content'); return false;">Roleplay</a></li> <li><a href="#" onclick="ajaxpage('news', 'content'); return false;">News</a></li> <li><a href="#" onclick="ajaxpage('match', 'content'); return false;">Match</a></li> <li><a href="#" onclick="ajaxpage('seg', 'content'); return false;">Seg</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 4) { ?> <h1>Handler</h1> <ul> <li><a href="#" onclick="ajaxpage('directory', 'content'); return false;">Directory</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 3) { ?> <h1>Booking</h1> <ul> <li><a href="#" onclick="ajaxpage('champions', 'content'); return false;">Champions</a></li> <li><a href="#" onclick="ajaxpage('booker', 'content'); return false;">Booker</a></li> <li><a href="#" onclick="ajaxpage('compiler', 'content'); return false;">Compiler</a></li> <li><a href="#" onclick="ajaxpage('archives', 'content'); return false;">Archives</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 2) { ?> <h1>Fed Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('handlers', 'content'); return false;">Handlers</a></li> <li><a href="#" onclick="ajaxpage('characters', 'content'); return false;">Characters</a></li> <li><a href="#" onclick="ajaxpage('applications', 'content'); return false;">Applications</a></li> <li><a href="#" onclick="ajaxpage('eventnames', 'content'); return false;">Event Names</a></li> <li><a href="#" onclick="ajaxpage('titlenames', 'content'); return false;">Title Names</a></li> <li><a href="#" onclick="ajaxpage('matchtypes', 'content'); return false;">Match Types</a></li> <li><a href="#" onclick="ajaxpage('divisions', 'content'); return false;">Divisions</a></li> <li><a href="#" onclick="ajaxpage('countries', 'content'); return false;">Arenas</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 1) { ?> <h1>Site Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('templates', 'content'); return false;">Templates</a></li> <li><a href="#" onclick="ajaxpage('content', 'content'); return false;">Content</a></li> <li><a href="#" onclick="ajaxpage('biosconfig', 'content'); return false;">Bio Configuration</a></li> <li><a href="#" onclick="ajaxpage('newscat', 'content'); return false;">News Categories</a></li> <li><a href="#" onclick="ajaxpage('menus', 'content'); return false;">Menus</a></li> </ul> <?php } ?> </div> <div id=content> </div> <div id="footer">Backstage 1 © 2009 </div> </div> </div> </body> </html> <?php ######################################### ######## ADMIN SCRIPT HAS TO END ABOVE ######################################### } } } else { // if they have not submitted the form ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Language" content="en-us"> <meta name="language" content="en-us"> <title>Backstage V1 Administration Console</title> <link rel="stylesheet" href="backstage.css" type="text/css" media="screen"> <link rel="stylesheet" href="backstage_print.css" type="text/css" media="print"> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script type="text/javascript" src="ajax.js"></script> <link rel=stylesheet href=backstage.css type=css media=screen> <link rel=stylesheet href=backstage_print.css type=css media=print> </head> <body> <div id=login> <form method="POST" action="/other/backstage4.php"> <h1>KOW Backstage</h1> <p><label>Username:<br><input type="text" name="username" id="log" tabindex="1"></label></p> <p><label>Password:<br><input type="password" name="password" id="pwd" tabindex="2"></label></p> <p style="text-align: center;"><input type="submit" class="button" name="submit" id="submit" value="Login »" tabindex="4"></p> </form> </div> </body> </html> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724059 Share on other sites More sharing options...
revraz Posted December 26, 2008 Share Posted December 26, 2008 Aren't you already doing that with logic like <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] <= 4) { ?> ? Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724067 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 Someone said I should put that there a while back and I didn't understand why. I should have had them explain that. Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724071 Share on other sites More sharing options...
revraz Posted December 26, 2008 Share Posted December 26, 2008 It's looking at the admin value. If it is equal or less than 4 then it does the code after it. If not, it doesn't. Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724073 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 Okay well I want it adjusted to where like instead of if equal or less than 4 then it does the code after it. If not, it doesn't. I want it to be like if the admin is 1 then it shows the sections that are supposed to be shown for the admins which is all but only sections 6 and 5 are also supposed to be shown by non admins which are two Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724075 Share on other sites More sharing options...
revraz Posted December 26, 2008 Share Posted December 26, 2008 Then apply that logic to your code. Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724076 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 So... For the ones that are supposed to be both are: if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1 & 2) { ?> And the ones that are just for admins are: if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1) { ?> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724078 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 I tried that but for some reason it doesn't like that & because I can tell its messing up what's viewable for each user. Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724080 Share on other sites More sharing options...
revraz Posted December 26, 2008 Share Posted December 26, 2008 If everyone can see 6 & 5, then there is no reason to check for that. Just check and see if admin is set to 1 and if it is, display the admin code. Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724082 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 What's wrong with this: For the ones that are supposed to be both are: if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1 & 2) { ?> And the ones that are just for admins are: if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1) { ?> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724085 Share on other sites More sharing options...
revraz Posted December 26, 2008 Share Posted December 26, 2008 Something like this <?php include ('database.php'); //if the login form is submitted if(isset($_POST['submit'])) { // makes sure they filled it in if(!$_POST['username'] || !$_POST['password']) { die('You did not fill in a required field.'); } $username = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['password']); $check = mysql_query("SELECT * FROM users WHERE username = '".$username."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database.'); } while($info = mysql_fetch_array( $check )) { $pass = md5(stripslashes($_POST['password'])); $info['password'] = stripslashes($info['password']); //$_POST['pass'] = md5($_POST['pass']); THIS IS DONE IN THE ABOVE STATEMENT //gives error if the password is wrong if ($pass != $info['password']) { die('Incorrect password, please try again.'); } else // if login is ok then we add a cookie and send them to the correct page { $username = stripslashes($username); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); // Finds out the user type $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $admin = $row['admin']; $_SESSION['admin'] = $admin; ######################################### ######## ADMIN SCRIPT CAN BE ADDED BELOW ######################################### if(isset($_SESSION['admin'])) { ?> <div id=container> <div class=header> <table cellpadding="0" cellspacing="0" border="0" width="95%"> <tr> <td width=110 align=center></td> <td></td> <td width=40 valign=bottom align=right> <a href="#" onclick="ajaxpage('home', 'content'); return false;">Home</a> | <a href="#" onclick="ajaxpage('logout', 'content'); return false;">Logout</a> | <a target="_blank" href="http://kansasoutlawwrestling.com/phpBB3">Forums</a></td> </tr> </table> </div> <div id=container2> <div id=nav> <h1>Character</h1> <ul> <li><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></li> <li><a href="#" onclick="ajaxpage('allies', 'content'); return false;">Allies</a></li> <li><a href="#" onclick="ajaxpage('rivals', 'content'); return false;">Rivals</a></li> <li><a href="#" onclick="ajaxpage('quotes', 'content'); return false;">Quotes</a></li> </ul> <h1>Submit</h1> <ul> <li><a href="#" onclick="ajaxpage('roleplay', 'content'); return false;">Roleplay</a></li> <li><a href="#" onclick="ajaxpage('news', 'content'); return false;">News</a></li> <li><a href="#" onclick="ajaxpage('match', 'content'); return false;">Match</a></li> <li><a href="#" onclick="ajaxpage('seg', 'content'); return false;">Seg</a></li> </ul> <h1>Handler</h1> <ul> <li><a href="#" onclick="ajaxpage('directory', 'content'); return false;">Directory</a></li> </ul> <h1>Booking</h1> <ul> <li><a href="#" onclick="ajaxpage('champions', 'content'); return false;">Champions</a></li> <li><a href="#" onclick="ajaxpage('booker', 'content'); return false;">Booker</a></li> <li><a href="#" onclick="ajaxpage('compiler', 'content'); return false;">Compiler</a></li> <li><a href="#" onclick="ajaxpage('archives', 'content'); return false;">Archives</a></li> </ul> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1 ) { ?> <h1>Fed Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('handlers', 'content'); return false;">Handlers</a></li> <li><a href="#" onclick="ajaxpage('characters', 'content'); return false;">Characters</a></li> <li><a href="#" onclick="ajaxpage('applications', 'content'); return false;">Applications</a></li> <li><a href="#" onclick="ajaxpage('eventnames', 'content'); return false;">Event Names</a></li> <li><a href="#" onclick="ajaxpage('titlenames', 'content'); return false;">Title Names</a></li> <li><a href="#" onclick="ajaxpage('matchtypes', 'content'); return false;">Match Types</a></li> <li><a href="#" onclick="ajaxpage('divisions', 'content'); return false;">Divisions</a></li> <li><a href="#" onclick="ajaxpage('countries', 'content'); return false;">Arenas</a></li> </ul> <h1>Site Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('templates', 'content'); return false;">Templates</a></li> <li><a href="#" onclick="ajaxpage('content', 'content'); return false;">Content</a></li> <li><a href="#" onclick="ajaxpage('biosconfig', 'content'); return false;">Bio Configuration</a></li> <li><a href="#" onclick="ajaxpage('newscat', 'content'); return false;">News Categories</a></li> <li><a href="#" onclick="ajaxpage('menus', 'content'); return false;">Menus</a></li> </ul> <?php } ?> </div> <div id=content> </div> <div id="footer">Backstage 1 © 2009 </div> </div> </div> <?php ######################################### ######## ADMIN SCRIPT HAS TO END ABOVE ######################################### } } } else { // if they have not submitted the form <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Language" content="en-us"> <meta name="language" content="en-us"> <title>Backstage V1 Administration Console</title> <link rel="stylesheet" href="backstage.css" type="text/css" media="screen"> <link rel="stylesheet" href="backstage_print.css" type="text/css" media="print"> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script type="text/javascript" src="ajax.js"></script> <script type="text/javascript"> var page = document.cookie.match(/page=[\w][\w\-\.]+;/); if(page != null) { ajaxpage("page", "content"); } else { ajaxpage("home", "content"); } </script> <link rel=stylesheet href=backstage.css type=css media=screen> <link rel=stylesheet href=backstage_print.css type=css media=print> </head> <body> <div id=login> <form method="POST" action="/other/backstage4.php"> <h1>KOW Backstage</h1> <p><label>Username:<br><input type="text" name="username" id="log" tabindex="1"></label></p> <p><label>Password:<br><input type="password" name="password" id="pwd" tabindex="2"></label></p> <p style="text-align: center;"><input type="submit" class="button" name="submit" id="submit" value="Login »" tabindex="4"></p> </form> </div> </body> </html> } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724087 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 Parse error: syntax error, unexpected T_ELSE in /home/content/y/a/n/yankeefaninkc/html/other/backstage4.php on line 160 <?php include ('database.php'); //if the login form is submitted if(isset($_POST['submit'])) { // makes sure they filled it in if(!$_POST['username'] || !$_POST['password']) { die('You did not fill in a required field.'); } $username = mysql_real_escape_string($_POST['username']); $pass = mysql_real_escape_string($_POST['password']); $check = mysql_query("SELECT * FROM users WHERE username = '".$username."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database.'); } while($info = mysql_fetch_array( $check )) { $pass = md5(stripslashes($_POST['password'])); $info['password'] = stripslashes($info['password']); //$_POST['pass'] = md5($_POST['pass']); THIS IS DONE IN THE ABOVE STATEMENT //gives error if the password is wrong if ($pass != $info['password']) { die('Incorrect password, please try again.'); } else // if login is ok then we add a cookie and send them to the correct page { $username = stripslashes($username); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); // Finds out the user type $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $admin = $row['admin']; $_SESSION['admin'] = $admin; ######################################### ######## ADMIN SCRIPT CAN BE ADDED BELOW ######################################### if(isset($_SESSION['admin'])) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Language" content="en-us"> <meta name="language" content="en-us"> <title>Backstage V1 Administration Console</title> <link rel="stylesheet" href="backstage.css" type="text/css" media="screen"> <link rel="stylesheet" href="backstage_print.css" type="text/css" media="print"> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script type="text/javascript" src="ajax.js"></script> <script type="text/javascript"> var page = document.cookie.match(/page=[\w][\w\-\.]+;/); if(page != null) { ajaxpage("page", "content"); } else { ajaxpage("home", "content"); } </script> <link rel=stylesheet href=backstage.css type=css media=screen> <link rel=stylesheet href=backstage_print.css type=css media=print> </head> <body> <div id=container> <div class=header> <table cellpadding="0" cellspacing="0" border="0" width="95%"> <tr> <td width=110 align=center></td> <td></td> <td width=40 valign=bottom align=right> <a href="#" onclick="ajaxpage('home', 'content'); return false;">Home</a> | <a href="#" onclick="ajaxpage('logout', 'content'); return false;">Logout</a> | <a target="_blank" href="http://kansasoutlawwrestling.com/phpBB3">Forums</a></td> </tr> </table> </div> <div id=container2> <div id=nav> <h1>Character</h1> <ul> <li><a href="#" onclick="ajaxpage('bio', 'content'); return false;">Bio</a></li> <li><a href="#" onclick="ajaxpage('allies', 'content'); return false;">Allies</a></li> <li><a href="#" onclick="ajaxpage('rivals', 'content'); return false;">Rivals</a></li> <li><a href="#" onclick="ajaxpage('quotes', 'content'); return false;">Quotes</a></li> </ul> <h1>Submit</h1> <ul> <li><a href="#" onclick="ajaxpage('roleplay', 'content'); return false;">Roleplay</a></li> <li><a href="#" onclick="ajaxpage('news', 'content'); return false;">News</a></li> <li><a href="#" onclick="ajaxpage('match', 'content'); return false;">Match</a></li> <li><a href="#" onclick="ajaxpage('seg', 'content'); return false;">Seg</a></li> </ul> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1 ) { ?> <h1>Handler</h1> <ul> <li><a href="#" onclick="ajaxpage('directory', 'content'); return false;">Directory</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1) { ?> <h1>Booking</h1> <ul> <li><a href="#" onclick="ajaxpage('champions', 'content'); return false;">Champions</a></li> <li><a href="#" onclick="ajaxpage('booker', 'content'); return false;">Booker</a></li> <li><a href="#" onclick="ajaxpage('compiler', 'content'); return false;">Compiler</a></li> <li><a href="#" onclick="ajaxpage('archives', 'content'); return false;">Archives</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1) { ?> <h1>Fed Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('handlers', 'content'); return false;">Handlers</a></li> <li><a href="#" onclick="ajaxpage('characters', 'content'); return false;">Characters</a></li> <li><a href="#" onclick="ajaxpage('applications', 'content'); return false;">Applications</a></li> <li><a href="#" onclick="ajaxpage('eventnames', 'content'); return false;">Event Names</a></li> <li><a href="#" onclick="ajaxpage('titlenames', 'content'); return false;">Title Names</a></li> <li><a href="#" onclick="ajaxpage('matchtypes', 'content'); return false;">Match Types</a></li> <li><a href="#" onclick="ajaxpage('divisions', 'content'); return false;">Divisions</a></li> <li><a href="#" onclick="ajaxpage('countries', 'content'); return false;">Arenas</a></li> </ul> <?php } ?> <?php if(isset($_SESSION['admin']) && $_SESSION['admin'] = 1) { ?> <h1>Site Admin</h1> <ul> <li><a href="#" onclick="ajaxpage('templates', 'content'); return false;">Templates</a></li> <li><a href="#" onclick="ajaxpage('content', 'content'); return false;">Content</a></li> <li><a href="#" onclick="ajaxpage('biosconfig', 'content'); return false;">Bio Configuration</a></li> <li><a href="#" onclick="ajaxpage('newscat', 'content'); return false;">News Categories</a></li> <li><a href="#" onclick="ajaxpage('menus', 'content'); return false;">Menus</a></li> </ul> <?php } ?> </div> <div id=content> </div> <div id="footer">Backstage 1 © 2009 </div> </div> </div> </body> </html> <?php ######################################### ######## ADMIN SCRIPT HAS TO END ABOVE ######################################### } } } else { // if they have not submitted the form ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Language" content="en-us"> <meta name="language" content="en-us"> <title>Backstage V1 Administration Console</title> <link rel="stylesheet" href="backstage.css" type="text/css" media="screen"> <link rel="stylesheet" href="backstage_print.css" type="text/css" media="print"> <script src="prototype.js" type="text/javascript"></script> <script src="scriptaculous.js" type="text/javascript"></script> <script type="text/javascript" src="ajax.js"></script> <link rel=stylesheet href=backstage.css type=css media=screen> <link rel=stylesheet href=backstage_print.css type=css media=print> </head> <body> <div id=login> <form method="POST" action="/other/backstage4.php"> <h1>KOW Backstage</h1> <p><label>Username:<br><input type="text" name="username" id="log" tabindex="1"></label></p> <p><label>Password:<br><input type="password" name="password" id="pwd" tabindex="2"></label></p> <p style="text-align: center;"><input type="submit" class="button" name="submit" id="submit" value="Login »" tabindex="4"></p> </form> </div> </body> </html> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724091 Share on other sites More sharing options...
revraz Posted December 26, 2008 Share Posted December 26, 2008 Well "something like this" was showing you the idea. Look at the code, and see why it thinks the ELSE doesn't belong there. It's not hard to find the error. Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724101 Share on other sites More sharing options...
Xtremer360 Posted December 26, 2008 Author Share Posted December 26, 2008 I think it has to do with one of the braces but I'm not sure. Quote Link to comment https://forums.phpfreaks.com/topic/138471-not-displaying-my-control-panel-after-successful-login/#findComment-724107 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.