<?php include("C:/xampp/htdocs/mySalon/connect_database.php");?>
			  
			 <?php 

if(isset ($_POST ['username']) && $_POST ['password']){
$username = $_POST['username'];
$password=$_POST['password'];




$query=mysql_query("SELECT * FROM admin WHERE username='$username'");
$numrows=mysql_num_rows($query);

if ($numrows!=0)
{

	while ($row=mysql_fetch_assoc($query))
	{
		$dbusername=$row['username'];
		$dbpassword=$row['password'];
	}
	//check to see if they match!
	if ($username==$dbusername&& md5 ($password)==$dbpassword)
	{
		
		header ('Location: http://localhost/mySalon/admin/admin_page.php');
		$_SESSION['username'] = $username;
	}
	else
		echo "Incorrect Password";
}
else 
 echo "You are not the administrator";
 }
else
  echo "";

?>

Recommended Answers

All 4 Replies

Member Avatar for diafol

ensure that there is NO output in the file prior to header(). That is, no error echo, no html, no whitespace, nothing.

If you check and there is definitely no output, you may have an issue witht he file format. You should save your files as UTF-8 WITHOUT BOM (e.g. in more advanced text editors like Notepad++). Often text editor will default to ANSI or other. BOMs cause 'invisible' output which mess up header().

get rid of the blank lines, they are output

Remove the outputs from your header.

In this instance simply delete the white spacing on lines 1 and two so delete everything before <?php on line 1 and 2.

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.