As title really, I don't understand why on login it is opening a new window and I would really prefer it not to! I use the header() function several times in my website yet this is the only occasion a new tab launches. A pointer in the right direction would be much appreciated as i've no idea why this is happening!
Code:
<?php
session_start();
include ("../scripts/connect_to_mysql.php");
$error_msg = "";
$loggedon = $_GET['loggedon'];
if ($loggedon)
{
$error_msg = '<font color="#FF0000">*To access this part of Queen\'s Radio, you must log in. </font>';
}
if (isset($_SESSION['admin']))
{
header("LOCATION: index.php");
exit;
}
if (isset($_POST['login']))
{
// username and password sent from form
$username = $_POST['username'];
$password = $_POST['password'];
// To protect MySQL injection
$username = mysqli_real_escape_string($myconnection,$username);
$password = mysqli_real_escape_string($myconnection,$password);
$password = md5($password);
$sql = "SELECT * FROM members WHERE username='$username' and password='$password'";
$result = mysqli_query($myconnection, $sql);
// Mysql_num_row is counting table row
$count=mysqli_num_rows($result);
// If result matched $username and $password, table row must be 1 row
if($count!=1){
$error_msg = '<font color="#FF0000">*Your login information is incorrect</font>';
}
else {
$_SESSION['admin'] = $username;
header("LOCATION: index.php");
exit;
}
}// close if post username
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Queen's Radio Admin Page</title>
<link href="../styles/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="outer-container">
<div id="inner-container">
<div id="header">
<img src="../images/newheader3.png" alt="Queen's Radio Logo" />
<ul id="nav">
<li id="nav_home"><a href="../index.php"></a></li>
<li id="nav_about"><a href="../about.php"></a></li>
<li id="nav_schedule"><a href="../schedule.php"></a></li>
<li id="nav_podcasts"><a href="../podcasts.php"></a></li>
<li id="nav_launch"><a href="../#"></a></li>
<li id="nav_news"><a href="../news.php"></a></li>
<li id="nav_links"><a href="../links.php"></a></li>
<li id="nav_contact"><a href="../contact.php"></a></li>
</ul>
</div> <!--end header-->
<div id="block_content_middle">
<div class="big-content-top">
<h4>ADMINISTRATOR ACCESS ONLY</h4>
<h5>Please enter your login details below...</h5>
</div> <!--end big content top-->
<div class="big-content-middle">
<?php
if (!isset($_SESSION['admin'])){
echo '
<form action="admin_check.php" method="post" target=' . htmlentities($_SERVER['PHP_SELF']) . '>
Username:<input type="text" name="username" id="username" />
<br/><br/>
Password:<input type="password" name="password" id="password" />
<br/><br/>
' . $error_msg . '
<br/><br/>
<input type="submit" name="login" id="login" value="Login" />
</form> ';
}
?>
</div> <!--end big content middle-->
<div class="big-content-bottom">
</div> <!--end big content bottom-->
</div> <!--end featured-->
</div>
</div>
<div id="footer">
<div id="footer_nav">
<img src="../Images/return_to_top_arrowtwo.png" alt="return_arrow" />
</div>
<div id="footer_container">
<span class="whitetext"> Copyright</span> <span class="bluetext">Queen's Radio</span> <span class="whitetext">| All Rights Reserved | Design by </span><span class="bluetext">Nick Shaw </span>
</div> <!--end footer_container-->
<div align="center"><a href="administrator">Admin</a></div>
</div> <!--end footer-->
</body>
</html>