<?php
// connection to MySQL server
mysql_connect('localhost','root','');
mysql_select_db('administration');
if (isset($_POST['submit'])) {
$loginUsername=$_POST['username'];
$loginPassword=$_POST['password'];
$MM_redirectLoginSuccess = "validated.php";
$MM_redirectLoginFailed = "admin.php";
$MM_redirecttoReferrer = true;
mysql_select_db('administration');
if(empty($_POST['username']) && empty($_POST['password'])) {
die('<div class="error_up">Both field was blank</div>
<br><br><div class="footer_padding">
© Copyright Cycle Tracks <span>®</span></div>
');
}
if(empty($_POST['username'])) {
die('<div class="error_up">Username field was blank</div>
<br><br><div class="footer_padding">
© Copyright Cycle Tracks <span>®</span></div>
');
}
if(empty($_POST['password'])) {
die('<div class="error_up">Password field was blank</div>
<br><br><div class="footer_padding">
© Copyright Cycle Tracks <span>®</span></div>
');
}
$loginUsername = get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername);
$password = get_magic_quotes_gpc() ? $password : addslashes($password);
$LoginRS_query = "SELECT username, password FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
$LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
}
else {
echo "<script type='text/javascript'>location.href='$MM_redirectLoginFailed';</script>";
}
}
?>
<html>
<head>
<title>Cycle Tracks Portal - Validation Page</title>
<style type="text/css" media="all">@import "images/style.css";
</style>
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/"/>
</head>
<body>
</body>
</html>
HELP needed on:
1. As you can see above, there is a validation for empty username and password.
2. At the bottom of the PHP codes, I've included the HTML codes.
3. I want the validation error messages to get printed into the body tag of the HTML codes without moving the HTML codes up before the PHP codes.
4. Please help.