

<!DOCTYPE html>
<html>
<head>
	<title>e FX Market</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
	<style type="text/css">
		body{
			background-color: #121d33;
			background-image: url('img/bg2');
			background-size: cover;
			font-family: 'Inter', sans-serif;
			
		}

		#logolog{
			margin: 40px auto;
			height: 50px;
			width: 400px;
		}

		#formarea{
			width: 500px;
			border-radius: 10px;
			height: 400px;
			background-color: white;
			margin: 30px auto;
			clear: both;
			display: table;
			padding: 30px;
			box-sizing: border-box;
		}

		.input{
			width: 100%;
			height: 50px;
			border-radius: 5px;
			background-color: #e8f0fe;
			box-sizing: border-box;
			border: 0.5px solid grey;
			padding-right: 10px;
		}

		#btn{
			width: 100%;
			height: 50px;
			margin-top: 20px;
			color: black;
			background-color: #ffc31a;
			border: 0px;
			font-size: 18px;
			border-radius: 5px;
			font-weight: bold;
			box-sizing: border-box;

		}

		#forget{
			width: 400px;
			height: 50px;
			margin: 5px auto;
			text-align: center;
			color: white;
		}

		@media only screen and (max-width: 600px) {
		  #formarea{
		  	max-width: 97%;
		  	max-height: auto;
		  }
		  
		  #forget{
		      max-width: 90%;
		  }

		}
	</style>
</head>


<body>
	
	

	<div id="formarea">
		<h3>Welcome Back!</h3>

		<form method="POST" action="<?php $current_file; ?>">
			<center>
				<?php

					require 'db_conn.php';

				?>

				<?php 
				if (isset($_POST['accountname'])&&isset($_POST['password'])) {
					$accountname = $_POST['accountname'];
					$password = $_POST['password'];

					$password_hash = md5($password);

					if (!empty($accountname)&&!empty($password)) 

					{
						$query = "SELECT `id` FROM `users` WHERE `accountname`='$accountname' AND `password`='$password_hash'";

						if ($query_run = mysqli_query($conn, $query)) {
							$query_num_rows = mysqli_num_rows($query_run);

							if ($query_num_rows==0) {
								echo "Invalid username/password combination";
							}elseif($query_num_rows==1){

								while($row = mysqli_fetch_assoc($query_run)) {
								  echo $id = $row['id'];
								   
								}
								
								$_SESSION['id']=$id;
								header('Location: dashboard.php');
							}
						}
					}else{
						echo "You must supply an account name or password";
					}
				}


				?>
				<span style="font-weight: bold;">Username</span> <br>
			<input type="text" name="accountname" placeholder="Enter Username" class="input">
			<p>Your username can be found at the bottom of any email we’ve ever sent you. Need a reminder? <a href="#">Send my Wallet ID</a></p>
			<span style="font-weight: bold;">Password</span> <br>
			<input type="password" name="password" placeholder="Password" class="input">
			</center>


			<center><input type="submit" name="" value="LOGIN" id="btn"></center>
			<p><a href="#" style="color: blue; text-decoration: none; float: right;" >Need some help?</a></p>
		</form>




		
	</div>

	<div id="forget">
		Don't have a wallet? <a href="register.php">Sign Up</a>
	</div>

</body>


</html>