I am extremely new to php, and I'm trying to create a user profile to display information from the database. My problem is that I keep getting "you need to specify a username!" which is from the echo of my if statement.
Could you point out to me why it isn't showing the username?
Below is my code for the profile.
<?php
    //check for a form submission
    if (isset($_GET['username'])){
        $username = $_GET['username'];
        $q = "SELECT * FROM student WHERE username = '$username'";
        $r = mysqli_query($dbc, $q);
        if(mysqli_num_rows($r) == 1) {
            die ("that user name could not be found!");
        }
        while($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){
            $firstname = $row['firstname'];
            $lastname = $row['lastname'];
            $age = $row['age'];
        }
?>
<?php
        } else die ("you need to specify a username!");
?>
Below is the login
<?php 
# Database Connetion:
include('config/setup.php');  
# Loggin authentication
if($_POST) {
    $q = "SELECT * FROM student WHERE username = '$_POST[user]' AND password = SHA1('$_POST[password]')";
    $r = mysqli_query($dbc, $q);
    if( mysqli_num_rows($r) == 1) {
        $_SESSION['username'] = $_POST['user'];
        header('Location: profile.php');
    }
}
 ?>
Below is my database connection and session start
<?php
//Setup File:
#Start Session:
session_start();
# Database Connection Here...
$dbc = mysqli_connect('localhost', 'dev', 'dev123', 'mvt') OR die ('Could not connect because: '.mysqli_connect_error());
?>
I set the session start in the connection file and called it using the include function below.
<?php include('config/setup.php'); ?>
Sorry if my code is messy, I am new to PHP and I'm still trying to grasp it.
<title><?php echo $page_title.' | '.$site_title; ?> </title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php include('config/css.php'); ?>
<?php include('config/js.php'); ?>
  <div class="container">
  <div class="masthead">
    <h3 class="text-muted"></h3>
    <nav>
      <ul class="nav nav-justified">
        <li class="active"><a href="index.php">Home</a></li>
        <li><a href="#">Projects</a></li>
        <li><a href="#">Services</a></li>
        <li><a href="#">Downloads</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </nav>
  </div>
    </div>
  <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                    <div class="panel panel-info">
                    <div class="panel-heading">
                        <strong>Login</strong> 
                    </div><!-- END Pannel heading -->
                        <div class="panel-body"> 
                            <form action="login.php" method="post">
                              <div class="form-group">
                                <label for="user">UserName</label>
                                <input type="text" class="form-control" id="user" name="user" placeholder="UserName">
                              </div>
                              <div class="form-group">
                                <label for="password">Password</label>
                                <input type="password" class="form-control" id="password" name="password" placeholder="Password">
                              </div>
                             <!--
                              <div class="checkbox">
                                <label>
                                  <input type="checkbox"> Check me out
                                </label>
                              </div>
                              --> 
                              <button type="submit" class="btn btn-default">Login</button>
                              <a href="registration.php">register</a>
                            </form> <!-- END of form -->
                        </div> <!-- END of pannel body -->
            </div><!-- END of Column -->
        </div><!-- END of ROW -->
        </div> <!-- END of container -->
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
 
    