this is my login code which works fine when someone registers and then logs in. What im trying to do is allow access for certain users to different pages as they're classed as admin users. However the username and password for them will already be set and they dont need to register. Would i be able to do all this from the login page? this is my code so far/.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<?php
    require('databaseConnect.php');
    session_start();

    // When a form is submitted it will insert the values into my database.
    if (isset($_POST['username'])){
        $username = $_POST['username'];
        $password = $_POST['password'];
    //Checking is user existing in the database or not
        $query = "SELECT * FROM `Test` WHERE username='$username' and password='".md5($password)."'";
        $result = mysql_query($query) or die(mysql_error());
        $rows = mysql_num_rows($result);
        if($rows==1){
            $_SESSION['username'] = $username;
            header("Location: index.php"); // This will redirect the user to index.php page. 
            }else{
                echo "<div class='form'><h3>Username/password is incorrect.</h3><br/>Click here to <a href='login.php'>Login</a></div>";
                }
    }else{

?>

<div class="testbox">
<img src="MorleyWasteLogo.png" alt="Logo" align="middle" style="width:340px;height:90px;" >

<h1>Login</h1>
<form action="" method="post" name="login">

<label id="icon" for="name"><i class="icon-user"></i></label>
<input type="text" name="username" id="name" placeholder="Username" required/>
<label id="icon" for="name"><i class="icon-shield"></i></label>
<input type="password" name="password" id="name" placeholder="Password" required/>

<input name="submit" type="submit" value="Login" />
<input type="reset" value="Reset"/>
<a href='registration.php'>Register Here</a>
</form>
</div>

<?php } ?>
</body>
</html>

You should refine your question. You asked "Would i be able to do all this from the login page?" which must be yes. But this means you'll have to code it up on the back and frontend to do as you wish.

In short yes to the question. But the question was not about your code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.