Footer not showing, although I included already?

Hello Expert,

Although I had already included the footer, it seems that if you view the source, my site here does not show the footer. Here is the source (including PHP):
<?php
// DO NOT EDIT BELOW HERE.

$title       = 'Join the Network';
$description = 'Join DiceHub to gamble online in seconds. The highest odds, with no rigs and large community are waiting for you!';
$activeMenu  = 'Join';
require 'header.php';
?>
<?php
// FORM VALIDATION

if (isset($_POST['submit'])) {
    $firstName = $_POST['firstName'];
    $lastName  = $_POST['lastName'];
    $email     = $_POST['email'];
    $username  = $_POST['username'];
    $password  = $_POST['password'];
}
// Username Check
$userCheck = $db->query("SELECT * FROM users WHERE username='" . $username . "'");
if (empty($firstName) || empty($lastName) || empty($username) || empty($password) || empty($email)) {
    if (empty($firstName)) {
        $errors[] = 'What should we call you?';
    }
    if (empty($lastName)) {
        $errors[] = 'On the case we address you formally.';
    }
    if (empty($username)) {
        $errors[] = 'This is the name that\'ll appear on your profile.';
    }
    if (empty($password)) {
        $errors[] = 'How are you going to login?';
    }
    if (empty($email)) {
        $errors[] = 'You missed the most important part!';
    }
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    $errors[] = 'This isn\'t a valid email address.';
} elseif ($username == $password) {
    $errors[] = 'For security, Your can\'t use the same username as your password.';
} elseif ($userCheck->num_rows > 0) {
    $errors[] = 'That username is already in use.';
}
?>


<!-- Registration Form -->
<div class="margin30p">
	<div id="main-wrapper">
		<div id="regForm">
			<form action="<?php
echo $_SERVER['PHP_SELF'];
?>" method="POST">

				<div>
				<div>
				<label for="firstName">First Name</label>
				<input type="text" id="firstName" maxlength="25" required name="firstName" class='form-control' name="firstName"/>
				</div>
				<div>
				<label for="lastName">Last Name</label>
				<input type="text" id="lastName" maxlength="25" required name="lastName" class='form-control' name="lastName"/>
				</div>
				<label for="email">Email</label>
				<input type="text" id="email" maxlength="100" required name="email" class='form-control' name="email"/>
				</div>
				<div>
				<label for="username">Username</label>
				<input type="text" id="username" autofocus maxlength="25" required name="username" class='form-control' name="username"/>
				</div>
				<div>
				<label for="password">Password</label>
				<input type="text" id="password" maxlength="100" required name="password" class='form-control' name="password"/>
				</div>
				
				<input type="submit" name="submit" id="submit" value="submit" required data-loading-text="Creating account..." class="btn btn-primary"/>
			</form>
		</div>
</div>
<?php
require 'footer.php';
?>

Open in new window

Andy_FangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
What you have posted above and the link you have provided are not the same - the HTML structure of the link is completely different.
0
Andy_FangAuthor Commented:
What you have posted above and the link you have provided are not the same - the HTML structure of the link is completely different.

What do you mean? Both are for the join.php located at dicehub.com/join.
0
GaryCommented:
Go to the link and search the source for margin30p (from the code above) - it doesn't exist.
There is no similarities in the code
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Andy_FangAuthor Commented:
Oh, my bad, here's header.php:
<?php

require $_DOCUMENT['root'] . 'db.php';
?>
<!DOCTYPE HTML>
<!--
 _______   __                      __    __            __       
/       \ /  |                    /  |  /  |          /  |      
$$$$$$$  |$$/   _______   ______  $$ |  $$ | __    __ $$ |____  
$$ |  $$ |/  | /       | /      \ $$ |__$$ |/  |  /  |$$      \ 
$$ |  $$ |$$ |/$$$$$$$/ /$$$$$$  |$$    $$ |$$ |  $$ |$$$$$$$  |
$$ |  $$ |$$ |$$ |      $$    $$ |$$$$$$$$ |$$ |  $$ |$$ |  $$ |
$$ |__$$ |$$ |$$ \_____ $$$$$$$$/ $$ |  $$ |$$ \__$$ |$$ |__$$ |
$$    $$/ $$ |$$       |$$       |$$ |  $$ |$$    $$/ $$    $$/ 
$$$$$$$/  $$/  $$$$$$$/  $$$$$$$/ $$/   $$/  $$$$$$/  $$$$$$$/  

PRIVATE PROPERTY, YOU ARE NOW TRESPASSING. BEWARE OF DOG.

-->
<html>
	<head>
		<title>
		<?php
echo $title;
?> • DiceHub
		</title>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8">
		<meta content="<?php
echo $description;
?> " name='description'>
		<link href='/images/favicon.png' rel='shortcut icon'>
		
		<!-- Latest compiled and minified CSS -->
		<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" type="text/css">
		
		<!-- DiceHub Core JavaScript -->
		<link rel="stylesheet" href="/assets/style.css" type="text/css">
		
		<!-- Load latest jQuery -->
		<script src="//code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
		
		<!-- Latest compiled and minified JavaScript -->
		<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" type="text/javascript"></script>
		

<script type='text/javascript'>
/*	This function sets the cookie	*/
function themeBeta(){
   days=30; // number of days to keep the cookie
   myDate = new Date();
   myDate.setTime(myDate.getTime()+(days*24 * 60 * 60 * 1000));
   document.cookie = 'theme=beta; expires=' + myDate.toGMTString();
}
/*	end of cookie function	*/
</script>
		<!-- DiceHub Core JavaScript -->
		<script src="/js.js" type="text/JavaScript"></script>

	</head>
	<body>
			<noscript>
		<div id="nojs">Is DiceHub not working properly? Try<a href="//www.enable-javascript.com/" rel="nofollow"> enabling JavaScript in your browser</a> and use <a href="//www.google.com/chrome/" rel="nofollow">Google Chrome</a> for the best experience!
		</div>
		</noscript>
		<nav class="navbar navbar-inverse favbar-fixed-top" role="navigation">
			<!-- Dicehub and toggle get grouped for better mobile display -->
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
					<span class="sr-only">
						Toggle navigation
					</span>
					<span class="icon-bar">
					</span>
					<span class="icon-bar">
					</span>
					<span class="icon-bar">
					</span>
				</button>
				<a class="navbar-brand" href="/">
					<img src="/images/brand-logo.png" width="25" alt='DiceHub Logo'>
					DiceHub
				</a>
			</div>
			<form class="navbar-form navbar-left" role="search" action="/gamble.php" method="post">
				<div class="form-group">
					<input type="text" class="form-control" placeholder="$1.00">
				</div>
				<button type="submit" class="btn btn-success">
					Gamble
				</button>
			</form>
			<ul class="nav navbar-nav navbar-right">
				<li <?php
if (!isset($activeMenu)) {
    // Highlight nothing.
} elseif ($activeMenu = 'Join') {
    echo 'class="active"';
} else {
    // Highlight no link.
}
?>
					>
					<a href="/join">
						Join
					</a>
				</li>
				<li class="dropdown">
					<?php
//Check do we have username and password
if (!$username && !$password) {
    echo '<a data-toggle="modal" href="#LoginHeader"><b>Sign In</b></a>';
} else {
    echo "<a data-toggle=\"modal\" href=\"#LoginHeader\"><b>Welcome $username" . '.' . '</b></a>';
}
?>
				</li>
			</ul>
			<!-- navbar-collapse -->
		</nav>

			<!-- Modal -->
			<div class="modal fade" id="LoginHeader" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
								&times;
							</button>
							<h4 class="modal-title center">
								Login to DiceHub
							</h4>
						</div>
						<div class="modal-body">
							<form class="form-horizontal" role="form">
								<div class="form-group">
									<label for="inputEmail1" class="col-lg-2 control-label">
										Username
									</label>
									<div class="col-lg-10">
										<input type="email" class="form-control" id="Email" placeholder="Email or Username" name="username" maxlength="25">
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword1" class="col-lg-2 control-label">
										Password
									</label>
									<div class="col-lg-10">
										<input type="password" class="form-control" id="inputPassword1" placeholder="Password" name="password" maxlength="25">
									</div>
								</div>
								<div class="form-group">
									<div class="col-lg-offset-2 col-lg-10">
										<div class="checkbox">
											<label>
												<input type="checkbox" name="rememberMe">
												Remember me next time
											</label>
										</div>
									</div>
								</div>
								<input type="button" class="btn btn-primary center" value="Login">
							</form>
						</div>
					</div>
				</div>
			</div>

Open in new window

0
GaryCommented:
Now it makes more sense
Your code never gets past what is in the header.php.
Add to your page as the first line
error_reporting(E_ALL);

This will then tell you where in the join page the error is occurring
It could be at any point in the php code.
0
Andy_FangAuthor Commented:
Thanks for the response Gary, it is greatly appreciated.

I turned error reporting = on, and it turns out the site malfunctioned because I had this code:
//Check do we have username and password
if (!$username && !$password) {
    echo '<a data-toggle="modal" href="#LoginHeader"><b>Sign In</b></a>';
} else {
    echo "<a data-toggle=\"modal\" href=\"#LoginHeader\"><b>Welcome $username" . '.' . '</b></a>';
}

Open in new window

in header.php.

Somehow, I am able to load the index.php fine if I add this in:

$username = '';
$password = '';

Open in new window


But the instant I remove it...

Notice: Undefined variable: username in /home/a7715142/public_html/header.php on line 112

Open in new window


How do I fix this?
0
GaryCommented:
At that point there is no such thing as $username or $password so it will burp
You need (at a quick glance) to have your form validation before you include the header

and then change that line that is erroring out to
if (!isset($username) || !isset($password)) {

I also changed it to an OR condition since if either of those are false then they cannot be logged in.

I think you will come across another problem if you are including that header on other pages, since those other pages will still not have a username or password - this is where you will need to be setting some session vars to hold the data.   But just fix this bit first then you can move on.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
Your code is susceptible to SQL Injection. You are passing unsanitized and unvalidated values from the user (via POST variables) into your SQL query. You should--at a minimum--properly validate all user input, and I would suggest reading up on prepared statements.
0
Ray PaseurCommented:
Maybe step back from this question and start over here for a look at the fundamentals?
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

It takes a while to absorb all of this, and structured learning can give you that time.  Just a thought... ~Ray
0
Andy_FangAuthor Commented:
Thanks, I should've passed it as a session var from the beginning!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.