<?php
include'function.php';
include 'connect_db.php'; 
include 'register.php'; 
	
	if($_SERVER["REQUEST_METHOD"] == "POST")
{

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

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


	$count=mysql_num_rows($query);
	$_SESSION['Username'] = $username;
	$_SESSION['Password'] = $password;
	
	if($username && $password == "")
{
die("Please enter in a name and password!");
}

if($count != 0)
{
while($num_row = mysql_fetch_assoc($query))
{
$Database_Name = $num_row['Username'];
$Database_Pass = $num_row['Password'];
}

	$_SESSION['Username']=$username;
				$r=MyProfile();
				
				header("location: index.php");
	}

else
	// If result matched $myusername and $mypassword, table row must be 1 row 
	{
			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" />

<script type="text/javascript" src="js/jquery-1.5.2.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>

		<div id="box-left">
		<h1 style=" color:white;"><a href="#" id="L">  Log in </a> <br><br>
		<a href="#" id="R"> Register</a> </h1>
		</div>
		<div id="box-right">
			 
	<div id="content-login">
<h1 style=" color:white;">Log in</h1>
		<form action="login.php" method="POST" style="margin-left:20px; margin-top: 40px;">
			Username <br><input type="text" size="50" maxlength="50" id="username" name="Username"><br/>
			Password<br> <input type="password" size="50" maxlength="50" id="password" name="Password"><br/>
	
			 <input type="submit" name= "btnsubmit"value="LOG IN" 
			 style="width: 100px;margin-left:5px; margin-top:20px;border-radius:0px;background-color:white;">
		</form>

	</div>
	<div id="content-register">
		
		<form action="register.php" method="Post">
			Name <br> <input type="text" size="60" maxlength="50" name="name"><br/>
			Age <br><input type="text" size="60" maxlength="50" name="Age"><br/>
			E-mail <br> <input type="text" size="60" maxlength="50" name="email"><br/>
			
			City <br><input type="text" size="60" maxlength="50" name="Lname"><br/>
			Username <br> <input type="text" size="60" maxlength="50" name="username"><br/>
			Password <br>  <input type="password" size="60" maxlength="50" name="password"><br/>
			Confirm Password<br> 
						<input type="password" size="60" maxlength="50" name="C_password"><br/><br>
			<input type="submit"name="btnsubmit" value="SUBMIT" 
			style="width:150px; height:25px; background-color:rgb(178,178,178); 
			font-weight:bold;font-size:15px;border-raduis:10px; font-family: arial, sans serif;
			color:black;margin:0 10px; 0 50px;">
			<input type="reset"  value="RESET" 
			style="width:150px; height:25px; background-color:rgb(178,178,178); 
			font-weight:bold;font-size:15px;border-raduis:10px; color:black;">
		</form>
		<div>
</div>


</body>

</html>