<?php
	session_start();
	session_destroy();
	$link=mysql_connect("localhost", "root")
	or die("could not connect to database server");
	mysql_select_db("ramones", $link) or die(mysql_error());
	
	if($_SERVER["REQUEST_METHOD"] == "POST")
{

	$username=addslashes($_POST['Username']); 
	$password=addslashes($_POST['Password']); 


	$_SESSION['Username'] = $username; 
	$_SESSION['Password']   = $password; 

	
	$sql="SELECT  * FROM user WHERE Username='$username' and Password='$password'";
	$query=mysql_query($sql);
	$row=mysql_fetch_array($query);
	$active=$row['active'];

	$count=mysql_num_rows($query);


	// If result matched $myusername and $mypassword, table row must be 1 row
	if($count==1)
	{
	session_register("Username");
	$_SESSION['user']=$username;

				header("location: index.php");
	}
	else 
	{
			echo "<script language='javascript'>
		alert('Your Username or Password is invalid')
		
		</script>";
	}
	
	
	}
?>

<html>
<title> Ramones </title>
<head>
<link rel="stylesheet" type="text/css" href="default.css" />

</head>
<body>

<div id="wrapper">

<div id="container">
	

	<div id="content">
		
		<div style="margin: 40px auto 40px auto;
width: 585px;
background:black;
height: 300px;
border-radius: 10px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
color:white;
">
	<div id="form">
		<h1 class="title"style="color:white;"> Log in </h1><br/>
		<form action="login.php" method="POST" style="margin-left:40px;">
			Username: <input type="text" size="30" maxlength="50" id="username" name="Username"><br/>
			Password: <input type="password" size="30" maxlength="50" id="password" name="Password"><br/>
			
			 <input type="submit" name= "btnsubmit"value="LOG IN" 
			 style="width: 100px;margin-left:120px;">
		</form>
		<a href="register.php" style="text-decoration:none; color:white; margin-left:130px; ">Click to Register</a>
	</div>
			
				<div class="clear"></div>
				
					
		</div>

	</div>

<div  class="clear"></div>

</div>
</div>

</body>

</html>