Jump to content

Adding control panel to main script


Xtremer360

Recommended Posts

What I am wanting to do is add this script to my main one meaning take all the coding and add it to it. That way once the user logs in it will send them to the control panel. How do I do this?

 

This is control panel script.

 

<html>
<head>
    <title>Backstage V2 - Administration Console</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<table cellspacing="0" cellpadding="0" width="100%">
    <tr>
        <td valign="top" width="150"><!-- Start Navigation -->
        <table class="navigation" cellspacing="0">
            <tr>
                <th>Character</th>
            </tr>
            <tr>
                <td>
                <a href="#">Bio</a>
                <a href="#">Allies</a>
                <a href="#">Rivals</a>
                <a href="#">Quotes</a>
                </td>
            </tr>
            <tr>
                <th>Submit</th>
            </tr>
            <tr>
                <td>
                <a href="#">Roleplay</a>
                <a href="#">News</a>
                <a href="#">Match</a>
                <a href="#">Seg</a>
                </td>
            </tr>
            <tr>
                <th>Handler</th>
            </tr>
            <tr>
                <td>
                <a href="#">Directory</a>
                </td>
            </tr>
            <tr>
                <th>Booking</th>
            </tr>
            <tr>
                <td>
                <a href="#">Champions</a>
                <a href="#">Booker</a>
                <a href="#">Compiler</a>
                <a href="#">Archives</a>
                </td>
            </tr>
            <tr>
                <th>Fed Admin</th>
            </tr>
            <tr>
                <td>
                <a href="#">Handlers</a>
                <a href="#">Characters</a>
                <a href="#">Applications</a>
                <a href="#">Event Names</a>
                <a href="#">Title Names</a>
                <a href="#">Match Types</a>
                <a href="#">Divisions</a>
                <a href="#">Arenas</a>
                </td>
            </tr>
            <tr>
                <th>Site Admin</th>
            </tr>
            <tr>
                <td>
                <a href="#">Templates</a>
                <a href="#">Content</a>
                <a href="#">Bio Configuration</a>
                <a href="#">News Categories</a>
                <a href="#">Menus</a>
                </td>
            </tr>
        </table>
        </td><!-- End Navigation -->
        <td valign="top">

        <!-- Main Content -->
        <h3>Upcoming Events</h3>

        <h2>Great American Nightmare</h2>

        <h3>Maintenance</h3>
        <h2>Records Requiring Editing</h2>
        <!-- End Main Content -->
        
        </td>
    </tr>
</table>
</body>
</html> 

 

This is my main script.

 

<?php 

require ('database.php');

//if the login form is submitted
if(isset($_POST['login']))
{
    // makes sure they filled it in
    if(!$_POST['username'] || !$_POST['pass'])
    {
        die('You did not fill in a required field.');
    }
    $username = mysql_real_escape_string($_POST['username']); 
    $pass = mysql_real_escape_string($_POST['pass']); 

    $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['pass']));
        $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_start();
            $_SESSION['username'] = $username; 
            $_SESSION['loggedin'] = time();
            
            // Finds out the user type
            $query = "SELECT `authlevel` FROM `users` WHERE `username` = '" . $username . "'";
            $result = mysql_query($query) or die(mysql_error()); 
            $row = mysql_fetch_array($result); 
            $authLevel = $row['authlevel'];
            $_SESSION['authlevel'] = $authLevel;
        
            // Sends them to correct page after login
            if($authLevel == "2")
            {
                $page = "admin.php";
            }
            else
            {
                $page = "backstage.php";
            }
            header("Location: $page"); 
        } 
    } 
} 
else 
{ 
// if they have not submitted the form
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Backstage V1 Administration Console</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php include('backstage.css'); ?>
</head>
<body>
<div id="login"> 
<center>
<h1>KOW Backstage</h1><br>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Username:</p>
<input type="text" name="username" maxlength="40" size="40">
<br><br> 
<p>Password:</p>
<input type="password" name="pass" maxlength="50" size="40"> 
<br><br>
<input type="submit" name="login" value="Login >>"><br><br>
</form>
</center>
</div>  
</body>
</html>
<?php
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/135429-adding-control-panel-to-main-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.